Using awk to count the number of occurrences of a word in a column

Use an array

awk '{count[$3]++} END {for (word in count) print word, count[word]}' file

If you want “block” specifically: END {print count["BLOCK"]}

Leave a Comment