perl -nle '/(\w*)/;$i{$1}++; END{print for keys %i;} ' words.txt