Re: [newbie] Command deleting one of two equal lines in a file
Rodolfo Medina wrote: Hi. Does it exist a linux command (or a sequence of commands) that looks into a file and delete one line if there are two equal? Todd Slater replied: uniq is the closest thing I know, but it requires lines to be sorted. Todd Bjrn Lundin repied: If you don't mind having your original file sorted, then cat input_file | sort | uniq result_file would give you what you want (in result_file). then you could add rm -f input_file mv result_file input_file to make the switch as in cat input_file | sort | uniq result_file rm -f input_file mv result_file input_file (the rm might be unnecessary) -- /Bjrn Maybe simply 'sort -u input_file' should give the same result. Rodolfo Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Join the Club : http://www.mandrakeclub.com
[newbie] Command deleting one of two equal lines in a file
Hi. Does it exist a linux command (or a sequence of commands) that looks into a file and delete one line if there are two equal? Thanks, Rodolfo Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Join the Club : http://www.mandrakeclub.com
Re: [newbie] Command deleting one of two equal lines in a file
Rodolfo Medina wrote: Hi. Does it exist a linux command (or a sequence of commands) that looks into a file and delete one line if there are two equal? Thanks, Rodolfo Or simply deletes strings within several files within a directory? [ Similar to Find and Replace only across multiple documents at the same time. ] -- Regards SnapafunFrank Big or small, a challenge requires the same commitment to resolve. Registered Linux User # 324213 Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Join the Club : http://www.mandrakeclub.com
Re: [newbie] Command deleting one of two equal lines in a file
Hi. Does it exist a linux command (or a sequence of commands) that looks into a file and delete one line if there are two equal? Thanks, Rodolfo Or simply deletes strings within several files within a directory? [ Similar to Find and Replace only across multiple documents at the same time. ] -- Regards SnapafunFrank No, I mean deleting one of two any equal lines within a file, automatically. Thanks, Rodolfo Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Join the Club : http://www.mandrakeclub.com
Re: [newbie] Command deleting one of two equal lines in a file
Rodolfo Medina wrote: Hi. Does it exist a linux command (or a sequence of commands) that looks into a file and delete one line if there are two equal? Thanks, Rodolfo Or simply deletes strings within several files within a directory? [ Similar to Find and Replace only across multiple documents at the same time. ] -- Regards SnapafunFrank No, I mean deleting one of two any equal lines within a file, automatically. Thanks, Rodolfo Sorry Rodolfo, but I was adding to your thread as it is similar to my own requirement. Hope someone here can answer both requests. SnapafunFrank Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Join the Club : http://www.mandrakeclub.com
Re: [newbie] Command deleting one of two equal lines in a file
On Sunday 31 October 2004 11:49, SnapafunFrank wrote: Rodolfo Medina wrote: Hi. Does it exist a linux command (or a sequence of commands) that looks into a file and delete one line if there are two equal? Thanks, Rodolfo Or simply deletes strings within several files within a directory? [ Similar to Find and Replace only across multiple documents at the same time. ] -- Regards SnapafunFrank No, I mean deleting one of two any equal lines within a file, automatically. Thanks, Rodolfo Sorry Rodolfo, but I was adding to your thread as it is similar to my own requirement. Hope someone here can answer both requests. SnapafunFrank Looks like a clear case calling for a scratch your own itch script. Bash should be able to do it all...I don't have time to sort it out for you guys. I'm not deft enough to just swing it out of my sleeve...maybe somebody else takes pity. Or do some reading yourselfs...roll up 'em sleeves,heh;) -- Good luck, HarM Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Join the Club : http://www.mandrakeclub.com
Re: [newbie] Command deleting one of two equal lines in a file
On Sun, Oct 31, 2004 at 09:40:00AM +0100, Rodolfo Medina wrote: Hi. Does it exist a linux command (or a sequence of commands) that looks into a file and delete one line if there are two equal? uniq is the closest thing I know, but it requires lines to be sorted. Todd -- Name that tune #2: Turn up the Eagles the neighbors are listening. Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Join the Club : http://www.mandrakeclub.com
Re: [newbie] Command deleting one of two equal lines in a file
On Sunday 31 Oct 2004 09:47, SnapafunFrank wrote: Rodolfo Medina wrote: Hi. Does it exist a linux command (or a sequence of commands) that looks into a file and delete one line if there are two equal? Thanks, Rodolfo Or simply deletes strings within several files within a directory? [ Similar to Find and Replace only across multiple documents at the same time. ] open a konsole and type man sed sed is a powerful stream editor and given a very simple script can handle hundreds of files repeating a list of commands on each one and saving each file before moving on to the next in a list. magnet Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Join the Club : http://www.mandrakeclub.com
Re: [newbie] Command deleting one of two equal lines in a file
Rodolfo Medina wrote: Hi. Does it exist a linux command (or a sequence of commands) that looks into a file and delete one line if there are two equal? Todd Slater replied: uniq is the closest thing I know, but it requires lines to be sorted. Todd Bjrn Lundin repied: If you don't mind having your original file sorted, then cat input_file | sort | uniq result_file would give you what you want (in result_file). then you could add rm -f input_file mv result_file input_file to make the switch as in cat input_file | sort | uniq result_file rm -f input_file mv result_file input_file (the rm might be unnecessary) -- /Bjrn Thanks indeed. I think this should work for me, I one case my file is just sorted. Cheers, Rodolfo Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Join the Club : http://www.mandrakeclub.com