Awk Program (10 lines of code) to extract the words from a text file and alphabetize them. ############################################################################################### # countWords.awk makes an alphabetical list of words in a text file with the frequecy of # occurrence of each word. # Usage: gawk -f countWords.awk file.txt ############################################################################################### BEGIN { while((getline l < ARGV[1])>0) { n=split(tolower(l),arr,"[^a-zA-Z]+") for(i=1; i<=n;i++) if(match(arr[i],"^[ \t\n]*$")<=0) if(arr[i] in freq) freq[arr[i]]++ else freq[arr[i]]=1 } k=0; for(v in freq) {k++; ind[k]=v} n=asort(ind) for(i=1;i<=n;i++) printf("%3d: name=%-20s frequency=%3d\n",i,ind[i],freq[ind[i]]) }