To do multiple sed expression in one line, you can use -e a few times according to your need. For example:
To subtitute 'little' with 'big' and 'lamb' with 'cow' in "Mary had a little lamb" we can use:
$ echo 'Mary had a little lamb' | sed -e 's/little/big/' -e 's/lamb/cow/'where -e is for expression flag, 's/little/big/' is the first expression and 's/lamb/cow/' is the second expression
Mary had a big cow
That's all.
2 comments:
between sed and awk which one is easier to use?
Need your advise. Tq
Hi Anonymous,
In my opinion, sed is easier to understand because it follows some command that being used in vi, like the 's' for subtitute
Post a Comment