How to find unique words from file linux

13,372

If I understand what you want to do correctly, then

grep -oE 'Man-[0-9]+' filename | sort | uniq -c

should do the trick. It works as follows: First

grep -oE 'Man-[0-9]+' filename

isolates all words from the file that match the Man-[0-9]+ regular expression. That list is then piped through sort to get the sorted list that uniq requires, and then that sorted list is piped through uniq -c to count how often each unique Man- word appears.

Share:
13,372
jan345
Author by

jan345

Updated on June 30, 2022

Comments

  • jan345
    jan345 almost 2 years

    i have a big file, teh lines look like this Text numbers etc. [Man-(some numers)] is lot of this Man-somenumbers is repeat in few lines, i want to count only unique Mans -words. I cant use unique file , because text before Man words is always different in each line. How can i count only unique Man-somenumbers words in file ?