title: How to swap text based on patterns at once with sed?
body: <p>Suppose I have 'abbc' string and I want to replace:</p>
  
  <ul>
  <li>ab -> bc</li>
  <li>bc -> ab</li>
  </ul>
  
  <p>If I try two replaces the result is not what I want:</p>
  
  <pre><code>echo 'abbc' | sed 's/ab/bc/g;s/bc/ab/g'
  abab
  </code></pre>
  
  <p>So what sed command can I use to replace like below?</p>
  
  <pre><code>echo abbc | sed SED_COMMAND
  bcab
  </code></pre>
  
  <p><strong>EDIT</strong>:
  Actually the text could have more than 2 patterns and I don't know how many replaces I will need. Since there was a answer saying that <code>sed</code> is a stream editor and its replaces are greedily I think that I will need to use some script language for that.</p>