Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove same line in a file

Status
Not open for further replies.

we2aresame

Technical User
Feb 10, 2003
128
CA
I have a file like:
aaa
bbb
aaa
ccc
aaa
ddd
now, I try to only keep one line represent the lines which include same data, that means, the new file will be like:
aaa
bbb
ccc
ddd
would you tell me how to do it, thanks.
 
thanks, but if the file like:
aaa
ccc
bbb
aaa

the result should be:

aaa
ccc
bbb

I just want to remove the same data lines, sort maybe not the best way, thanks.
 
Try this (untested)

awk '{if (!a[$0]){a[$0]=1;print}}' infile > outfile

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top