The role of the uniq command: display only the lines, only for the consecutive lines that are repeated!
The following is a practical example:
[root@stu100 ~]# cat test
boy took bat home
Boy took bat home
girl took bat home
dog brought hat home
dog brought hat home
dog brought hat home
Look at the contents of the test file, you can see the continuous repeating lines
[root@stu100 ~]# uniq test
boy took bat home
girl took bat home
dog brought hat home
uniq command without any parameters, only shows consecutive repeated lines
[root@ Stu100 ~]# uniq -c test
2 boy took bat home
1 girl took bat home
3 dog brought hat home
The -c parameter displays the number of consecutive occurrences of each line in the file.
[root@stu100 ~]# uniq -d test
boy took bat home
dog brought hat home
- The d option only displays rows that appear repeatedly in the file.
[root@stu100 ~]# uniq -u test
girl took bat home
-u option shows no consecutive lines in the file .
[root@stu100 ~]# uniq -f 2 -s 2 test
boy took bat home
Ignore the first 2 lines of each line Field, ignoring the second white space and the first character of the third field, the result at home
[root@stu100 ~]# uniq -f 1 test
boy took bat Home
dog brought hat home
Ignore the first field of each line, so that the lines beginning with boy and girl seem to be consecutive lines.
Today I made a simple ftp server for the company, and it was the first time I actually did the serv
#ls -l | Wc -l Note: The total usage also takes 1 row, so the statistics are 14 instead of 13 Other
Computer store news: Do you remember that Steam is ready to host? Now there is new news: this hardwa
JFS was developed by IBM and originally appeared on the AIX operating system, which provides a log-b
Xen's rapid deployment basics tutorial
Linux system uses NFS to achieve file sharing
Linux operating system failure skills
Practical recommendation: 12 Linux system recovery tools
Kdump and crash configuration methods and failure analysis methods
More than 80 common Linux commands and tools
Use of queues in Linux process scheduling
Play Samba server Samba to build a whole process
How can I solve the Win7 Local Group Policy Editor?
What are the important functions of the Win8 system ODBC data source?
What should I do if the desktop is not displayed after the Win7 system computer is turned on?
Win7 optimization settings method
Win7 firewall how to close the firewall shutdown command execution step
Why Win8 system disk name can not be modified
Responding to the software incompatibility of Win8 system has a trick
Winxp boot press F11 to enter the system solution winxp can not enter the system