Maybe something like this:
sed 's/ab/~~/g; s/bc/ab/g; s/~~/bc/g'
Replace ~
with a character that you know won’t be in the string.
More Related Contents:
- How can I do a recursive find/replace of a string with awk or sed?
- Recursively rename files using find and sed
- Find and replace with sed in directory and sub directories
- How to replace an entire line in a text file by line number
- Remove all text before colon
- Case-insensitive search and replace with sed
- How do I find and replace all occurrences (in all files) in Visual Studio Code?
- Replace column in one file with column from another using awk?
- Replace a word with multiple lines using sed?
- Using get() with replacement functions
- How to use python regex to replace using captured group? [duplicate]
- Can I use sed to manipulate a variable in bash?
- Find and replace in Visual Studio code in a selection
- shell – remove numbers from a string column [closed]
- How to pass a variable containing slashes to sed
- Java how to replace 2 or more spaces with single space in string and delete leading and trailing spaces
- What is the difference between these (bCondition == NULL) and (NULL==bCondition)?
- Understanding implicit in Scala
- “var” or no “var” in JavaScript’s “for-in” loop?
- Replace last occurrence of a string in a string
- How to address error “bash: !d’: event not found” in Bash command substitution [duplicate]
- How to break a long line of code in Golang?
- How do I replace all occurrences of a string in JavaScript?
- How to convert Set to Array?
- String.Replace() vs. StringBuilder.Replace()
- Why does sed not replace all occurrences?
- How to search and replace with a counter-based expression in Vim?
- Using sed to insert file content
- Why does VIM have its own regex syntax?
- Regexp finding longest common prefix of two strings