I am using two files in my command, the first file (file1
) is just a file with every letter of the alphabet on individual lines. The second file ($w
in my command) is a giant word list. I have to compare the alphabet list to the word list to find words containing a letter from the alphabet exactly twice, show how many of those words there are for each letter, and an example word. The output would be something like this but for the entire alphabet
v 94 bivalve
w 94 awkward
x 3 executrix
y 196 abysmally
z 58 bedazzle
Below is my command and its output
for i in `cat file1`; do grep $i.*$i $w | sort | uniq -c | head -1; done
1 aardvark
1 abba
1 acacia
1 abandoned
1 abalienate
1 affability
1 ageing
1 aforethought
1 abalienation
1 hajj
1 backstroke
1 abnormally
1 accommodate
1 abalienation
1 abdominous
1 agitprop
1 quinqevalent
1 aardvark
1 abbess
1 abatement
1 absquatulate
1 bivalve
1 awkward
1 executrix
1 abysmally
1 bedazzle
grep
. Also see Why does my shell script choke on whitespace or other special characters?