iFocus.Life News News - Breaking News & Top Stories - Latest World, US & Local News,Get the latest news, exclusives, sport, celebrities, showbiz, politics, business and lifestyle from The iFocus.Life,

How to Count the Number of Columns in AWK

104 39
    • 1). Open a terminal. On Windows, click "Start," select "Run" and type "cmd." On Mac OS X, press "Cmd-Space" and type "Terminal." On Linux or Unix, a terminal icon is located somewhere on the desktop or menu bar.

    • 2). Type the following command:

      awk '{print NF}'

      "NF" stands for "Number of Fields," and typing this command will take you to a prompt where you can type some information. As soon as you hit enter, AWK will tell you how many fields (in this case, words) your information contains.

    • 3). Type the following to have awk perform the same function on the contents of a text file:

      awk '{print NF}' < textfile.txt

      Replace "textfile.txt" with a real text file.

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time
You might also like on "Technology"

Leave A Reply

Your email address will not be published.