書名: Learning Linux Shell Scripting作者名: Ganesh Naik本章字數: 102字更新時間: 2021-06-25 22:02:50
The uniq command
The following are a few examples showing the usage of the uniq command:
- This command removes duplicate adjacent lines from the file:
$ cat test aa aa cc cc bb bb yy zz $ uniq test
- This output removes the duplicate adjacent lines from test file, shown as follows:
aa cc bb yy zz
- The next command only prints duplicate lines:
$ uniq -d test
- Output:
aa cc bb
- The following command prints the number of occurrences of all elements on an inpidual line:
$ uniq -c test
- Output:
2 aa 2 cc 2 bb 1 yy 1 zz