uniq:tldr:21d52
This command performs a series of operations on the contents of the file specified by the variable ${filename}
.
-
sort ${filename}
: This command sorts the lines in the file in ascending order. The${filename}
variable represents the name of the file. -
uniq -c
: This command eliminates adjacent duplicates and displays only unique lines. The-c
option also reports the number of occurrences of each unique line. -
sort -nr
: This final command sorts the lines again, but this time in descending order (-r
option) based on the count of occurrences (-n
option), which was added by the previousuniq -c
command.
In summary, this command sorts the lines in the file, removes duplicate lines, and then sorts the unique lines in descending order of their occurrence count.