In this tutorial, I use uniq command to report or omit repeated lines in Linux. Now, let’s go uniq command in Linux for example.
Table of Contents
What does uniq command mean?
uniq – report or omit repeated lines
Syntax
uniq [OPTION]... [INPUT [OUTPUT]]
In the man page, the describes it
- uniq – report or omit repeated lines.
- man uniq – More details information about uniq command.

uniq command in Linux with example
I have created a file uniq_command.txt as below
[vagrant@DevopsRoles ~]$ cat uniq_command.txt HuuPV, My website DevopsRoles.com and HuuPhan.com.SN:199x. Devops Roles. Devops Roles. Devops Roles. Devops Roles. Hello world :)
Remove duplicate lines with uniq command.
[vagrant@DevopsRoles ~]$ uniq uniq_command.txt HuuPV, My website DevopsRoles.com and HuuPhan.com.SN:199x. Devops Roles. Hello world :)
The number of times a line was repeated
[vagrant@DevopsRoles ~]$ uniq -c uniq_command.txt 1 HuuPV, My website DevopsRoles.com and HuuPhan.com.SN:199x. 4 Devops Roles. 1 1 Hello world :)
It only prints the repeated lines.
[vagrant@DevopsRoles ~]$ uniq -d uniq_command.txt Devops Roles.
Prints all repeated duplicate line
[vagrant@DevopsRoles ~]$ uniq -D uniq_command.txt Devops Roles. Devops Roles. Devops Roles. Devops Roles.
How to not print the duplicate lines. Only the unique lines.
[vagrant@DevopsRoles ~]$ uniq -u uniq_command.txt HuuPV, My website DevopsRoles.com and HuuPhan.com.SN:199x. Hello world :)
Conclusion
uniq command is a simple command in Linux. It is used to report or omit repeated lines. Thank you for reading the DevopsRoles page!