uniq command in linux

uniq command in linux allows you to filter unique lines. There are several flags you can use with uniq command.

uniq command in linux

uniq command in linux with examples
uniq command in linux


uniq command in linux is used to get the unique or duplicate line from the file. If you extract unique or duplicate content from a file then you need to use uniq command.
 
But uniq command works only in the sorted file. So before use "uniq" command you must sort your file using sort command.

Now let's see how you can use it,
uniq command to display unique lines
uniq command to display unique lines

$uniq fileName
  • Before using "uniq" command.
  • sort your file using the sort command and save to new file.
  • Then write "uniq fileName" and press ENTER.
  • It will eliminate duplicate lines and print uniqe lines.

To display duplicate lines from the file

uniq command to display repeated lines with examples
uniq command to display repeated lines

$uniq -d fileName
  • To display repeated lines from the file.

To display lines which are not repeated

uniq command to display non-repeated lines with examples
display non-repeated lines

$uniq -u fileName
  • To display non-repeated lines from a files.

To print No.of times the line repeated

uniq command to print number of times the line repeated
No.of times the line repeated

$uniq -c fileName
  • If you want to know how many times the paticular line repeated.
  • Then you have to use "-c" flag with "uniq" command.
  • Just write "uniq -c fileName" and press ENTER.
  • This will show No.of times the line repeated at the begining of the line.

case insensitive

uniq command to display case insensitive format
case insensitive

$uniq -i fileName
  •  uniq is case sensitive to make it case insensitive.
  • You can use "-i" flag to ignore cases.

Conclusion

These are the most used flags in uniq command in linux. To learn more about uniq just use man command.

HAVE A NICE DAY💙

Related,

Name

Apps,3,Games,1,Linux,38,Linux Commands,37,Terminal Apps,2,Termux,17,Userland,3,Windows,1,
ltr
item
Pro Tech guides: uniq command in linux
uniq command in linux
uniq command in linux allows you to filter unique lines. There are several flags you can use with uniq command.
https://blogger.googleusercontent.com/img/a/AVvXsEj7dNDA4VxfkA7xvX0v_MxMEh5Bh3BOGFYhIk9RBtalxrTa3wmePiubB8SXpd3f0D3Z1x6_QdRl3Dgjz1q4v6vUrF9_BfY0xr9FPWrPMIebM5Db9HeIwpSI01vbLnc9DJeWl60gvXlvsAQSaOJnqkY-KCUxh7UBWRaAu8oPUm0fEi0YkaoLaoJrnH23=s16000
https://blogger.googleusercontent.com/img/a/AVvXsEj7dNDA4VxfkA7xvX0v_MxMEh5Bh3BOGFYhIk9RBtalxrTa3wmePiubB8SXpd3f0D3Z1x6_QdRl3Dgjz1q4v6vUrF9_BfY0xr9FPWrPMIebM5Db9HeIwpSI01vbLnc9DJeWl60gvXlvsAQSaOJnqkY-KCUxh7UBWRaAu8oPUm0fEi0YkaoLaoJrnH23=s72-c
Pro Tech guides
http://www.protechguidez.com/2021/12/uniq-command-in-linux.html
http://www.protechguidez.com/
http://www.protechguidez.com/
http://www.protechguidez.com/2021/12/uniq-command-in-linux.html
true
7053638852026728047
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content