2

So I have this text document with 89 lines. In this document the first column of every line is another language. My task is to count how many different starting letters are used in the document. I think I have to use some sort of sort command with uniq, but I am not sure how to do this.

Snapshot from pastebin:

Adyghe Adygea
Albanian Albania        
Aragonese Aragon
Armenian Armenia, Nagorno-Karabakh
Aromanian
...
Wymysorys Poland
Võro  
Walloon Wallonia
Welsh Wales
3

This ought to cover it

cut -c1 filename | sort -u | wc -l

Using your data on pastebin it gives a result of 21.

The cut just plucks out letter 1, the sort has the -u flag for unique, and then piped into wc to give a line count.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.