Wordfreq

Use awk to list the thirty most-common words in a text file
{  nbytes += length($0) + 2 # +2 for CR/LF nfields += NF    $0 = tolower($0) for (i=1; i<=NF; i++) { arr[$i]++ } } END { show = (show == "") ? 30 : show width1 = length(show) PROCINFO["sorted_in"] = "@val_num_desc" for (i in arr) { if (width2 == 0) { width2 = length(arr[i]) } if (n++ >= show) { break } printf("%*d %*d %s\n",width1,n,width2,arr[i],i) }    printf("input: %d records, %d bytes, %d words of which %d are unique\n",NR,nbytes,nfields,length(arr)) exit(0) }
 * 1) Usage: awk -f wordfreq textfile.txt