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

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

E.S. Rosenberg esr at g.jct.ac.il
Wed Sep 25 14:43:29 IDT 2013


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 <vordoo at yahoo.com>:
> 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 at cs.huji.ac.il
> http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
>



More information about the Linux-il mailing list