The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 01-25-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,805

Code:
# this prints only one line for each distinct record in oldfile
awk '!x[$0]++' oldfile > newfile

# this completely removes all occurrances of all duplicated lines
awk 'x[$0]++ == 2' oldfile > t.sed
grep -v -f t.sed  oldfile > newfile

The other given solutions are data dependent, ie., using the special characteristics of duplicated data in your example to filter.