awk is a programming language. We don't have the time to learn it but here are some snippets that are useful. awk program (command line) to count occurences of consecutively appearing word in one column. This could be in a pipeline after sorting one-word lines. awk '{if($1!=p) {print p,c; c=1; p=$1} else c++} END{print p,c}' Example of using it to count each word of a file: tr -dc 'a-zA-Z \n' max) { max = length line = $0 }} END {print line}' myfile frequency of words in file: awk '{for (i=1; i<=NF; i++) count[$i]++} END {for (word in count) print word, " ", count[word]}' myfile