Re: replace string foo to bar AND bar to foo in the same file

2013-10-25 Thread E.S. Rosenberg
echo foobar foo bar | sed 's/foo/@foo/g; s/bar/@bar/g; s/@foo/bar/g; s/@bar/foo/g' based on: http://stackoverflow.com/questions/13991017/swap-two-strings-simultaneously found through: https://www.google.co.il/search?q=sed+swap+foo+and+bar חג שמח, Eliyahu - אליהו 2013/9/25 vordoo

replace string foo to bar AND bar to foo in the same file

2013-09-25 Thread vordoo
Hi, I know how to: sed -i 's/foo/bar/g' *.txt But how do I: replace string foo to bar AND bar to foo in the same file?? Thanks! ___ Linux-il mailing list Linux-il@cs.huji.ac.il

Re: replace string foo to bar AND bar to foo in the same file

2013-09-25 Thread Omer Zak
Some context is missing - is it an one-shot job to be carried manually, or do you plan to run it automatically from a script? In principle, you first do: egrep thirdstring *.txt to make that the string 'thirdstring' does not exist anywhere. A script would need a way to select another

Re: replace string foo to bar AND bar to foo in the same file

2013-09-25 Thread E.S. Rosenberg
Re:all echo foobar foo bar | sed 's/foo/@foo/g; s/bar/@bar/g; s/@foo/bar/g; s/@bar/foo/g' based on: http://stackoverflow.com/questions/13991017/swap-two-strings-simultaneously found through: https://www.google.co.il/search?q=sed+swap+foo+and+bar חג שמח, Eliyahu - אליהו 2013/9/25 E.S. Rosenberg

Re: replace string foo to bar AND bar to foo in the same file

2013-09-25 Thread vordoo
Done, THANK YOU! ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il

Re: replace string foo to bar AND bar to foo in the same file

2013-09-25 Thread Shlomi Fish
Hi vordoo, On Wed, Sep 25, 2013 at 2:24 PM, vordoo vor...@yahoo.com wrote: Hi, I know how to: sed -i 's/foo/bar/g' *.txt But how do I: replace string foo to bar AND bar to foo in the same file?? This is not hard to do using perl: shlomif@telaviv1:~$ perl -ple 'my $s1 = foo; my $s2 =