LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   conditional replacment with regexps? (https://www.linuxquestions.org/questions/linux-general-1/conditional-replacment-with-regexps-237505/)

MadCactus 10-01-2004 08:38 AM

conditional replacment with regexps?
 
Hi,

Suppose I have some text with a whole load of a's and b's, how can I create a regexp to replace the a's with b's and the b's with a's?

theYinYeti 10-01-2004 08:46 AM

sed 's/a/-=-TMP-=-/g; s/b/a/g; s/-=-TMP-=-/b/g'

But I guess tr 'ab' 'ba' should work.

Yves.

MadCactus 10-01-2004 09:19 AM

Suppose I was using emacs though?


All times are GMT -5. The time now is 01:56 AM.