Tuesday, May 21, 2013

28 - Counting repetitious lines in a file:

If there are some lines in a file which are duplicated, one can count and sort them with using the following command:

$ cat filename | sort | uniq -c | sort -nr

If someone interested to delete the repetitious line from the file, the following command would be useful:

$ sort filename | uniq > filename_2

No comments:

Post a Comment