Computing.Net > Forums > Unix > sed - delete duplicate lines

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

sed - delete duplicate lines

Reply to Message Icon

Name: snomys
Date: August 2, 2006 at 05:06:30 Pacific
OS: win nt
CPU/Ram: pentium 4/256
Product: IBM
Comment:

ive tried all the possibilties on the sed one liners sites, and tried everything mysefl, but i cant figure it out...

ive got a file, containing duplicate lines, like this


delete from itm.tb_wf_objects where alert_id = 51573
delete from itm.tb_wf_objects where alert_id = 51597
delete from itm.tb_wf_objects where alert_id = 51617
delete from itm.tb_wf_objects where alert_id = 51617

as you can see alert id 51617 appears twice, i want to rmeove all lines that have the same alert_ids. table names can change as well.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: August 2, 2006 at 08:34:42 Pacific
Reply:

I don't think sed is the best tool. If your file is already sorted simply use the uniq command:

cat myfile|uniq

If the file isn't sorted, sort it with the unique switch:

sort -u myfile



0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: sed - delete duplicate lines

How to delete duplicate lines ?? www.computing.net/answers/unix/how-to-delete-duplicate-lines-/8277.html

sed delete minus one www.computing.net/answers/unix/sed-delete-minus-one/3572.html

Delete first line of a file www.computing.net/answers/unix/delete-first-line-of-a-file/7594.html