![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Remove Duplicate lines from File | Nysif Steve | UNIX for Dummies Questions & Answers | 18 | 09-09-2007 05:57 AM |
| How to redirect duplicate lines from a file???? | zing_foru | UNIX for Dummies Questions & Answers | 3 | 04-25-2007 04:03 AM |
| Duplicate lines in the file | guptan | UNIX for Advanced & Expert Users | 3 | 05-18-2006 02:28 AM |
| Remove Duplicate Lines in File | Teh Tiack Ein | Shell Programming and Scripting | 5 | 01-12-2006 04:30 AM |
| Removing duplicate lines ignore case | hellsd | UNIX for Dummies Questions & Answers | 17 | 12-02-2004 06:47 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
removing duplicate lines from a file
Hi,
I am trying to remove duplicate lines from a file. For example the contents of example.txt is: this is a test 2342 this is a test 34343 this is a test 43434 and i want to remove the "this is a test" lines only and end up with the numbers in the file, that is, end up with: 2342 34343 43434 thanks |
| Forum Sponsor | ||
|
|
|
|||
|
Quote:
Code:
grep -v "[[:alpha:]]" file |
|
|||
|
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 |