title: Bash removing path from path variable and sed command
body: <p>Working with this code</p>
  
  <p><a href="https://stackoverflow.com/questions/370047/what-is-the-most-elegant-way-to-remove-a-path-from-the-path-variable-in-bash">What is the most elegant way to remove a path from the $PATH variable in Bash?</a></p>
  
  <pre><code>export PATH=`echo ${PATH} | awk -v RS=: -v ORS=: '/SDE/ {next} {print}'` | sed 's/:*$//'
  </code></pre>
  
  <p>In this instance if I run just the:</p>
  
  <pre><code>export PATH=`echo ${PATH} | awk -v RS=: -v ORS=: '/SDE/ {next} {print}'`
  </code></pre>
  
  <p>I can get the path containing <code>/SDE/</code> removed; however a <code>:</code> remains.  The <code>sed</code> command after I am assuming should remove that.  When I run this entire command at once nothing gets removed at all.  What is wrong with the <code>sed</code> statement that is causing the path not to update and how can I make the <code>sed</code> command remove the colon <code>:</code> after the <code>/SDE/</code> path variable is removed. </p>