Linux Tip: Multiple Sed Instructions In One Command

It’s possible to run several commands in a sed one-liner. All you have to do is separate the instructions with a semicolon:

 echo '123456' | sed 's/1/a/g; s/a2/x/g'
 output: x3456  

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>