Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash : grep unique lines

Tags:

grep

bash

uniq

I'd like to grep unique line. This is the file content:

this is line 1
this is line 1
this is line 2
this is line 1
this is line 1

I just want to output this is line 2 to my shell. How can I do that?

like image 469
Lazuardi N Putra Avatar asked Dec 18 '25 17:12

Lazuardi N Putra


1 Answers

sort x.txt |uniq -u

assuming your file is in x.txt which gives

this is line 2 
like image 59
KeepCalmAndCarryOn Avatar answered Dec 20 '25 11:12

KeepCalmAndCarryOn