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

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

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest