What does `-e` option in sed do?

I am trying to understand a shell script that uses sed. I found that there were some places where sed was invoked with the -e option.

I tried to see the man page and it just mentions,

-e command

Append the editing commands specified by the command argument to the list of commands.

which is not very clear to me.

Can someone kindly explain to me what the -e does? Thanks.

PS: I am using sed in mac

1 Answer

The -e parameters tells sed that you wish to supply multiple commands:

sed -e 's/string1/string2/g' -e 's/string4/string5/g'

This will replace string1 with string2 and string4 with string5.

4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like