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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To You Scripting Guru's

Status
Not open for further replies.

Germo

Technical User
Mar 29, 2004
123
GB
Hi All,

I have a file with 7500 lines in, some of the lines of data are duplicate line.... I would like a one line command that will search through the file and pull out one entry of each duplicate line and show it to screen or file?

If I do

#grep fred file1

I'll get all the lines that have "fred" in it printed to screen... all I am after is one printed to screen or file.

I hope you know what I mean.

Thanks in advance
Terry
 
You could pipe through 'sort -u' to remove duplicate lines.
 
Code:
sort file1 | uniq -d

Will print one copy of each duplicated line, no matter how many times it is duplicated.

- Rod



IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

A Simple Code for Posting on the Web
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top