Multiple sed commands

In all the previous examples, we only applied one sed command to our stream. What about running multiple sed commands?

You can do that by using theĀ -e option and separating the commands with a semicolon like this:

$ sed -e 's/First/XFirst/; s/Second/XSecond/' myfile

Also, you can enter every command on a separate line and you will achieve the same result:

$ sed -e '
> s/First/XFirst/
> s/Second/XSecond/' myfile  

The sed command offers great flexibility; if you use it well, you will gain a lot of power.