+1 vote
in Programming Languages by (10.5k points)
In my file, one of the columns has some special string and I want to know its count. The columns are tab separated. How can I find its total count using awk/gawk command?

1 Answer

0 votes
by (13.5k points)

If your file is not zipped, you can try the following awk command:

awk 'BEGIN{FS="\t";}{if ($column_number=="your_string") i++}END{print i}' filename

If your file is zipped, you can try the following awk command:

zcat zipped_file | awk 'BEGIN{FS="\t";}{if ($column_number=="your_string") i++}END{print i}'

Replace column_number with the column number in your file and your_string with your special string.

...