Combining two sed commands

sed is a scripting language. You separate commands with semicolon or newline. Many sed dialects also allow you to pass each command as a separate -e option argument.

sed -i 's/File//g;s/MINvac\.pdb//g' /home/kanika/standard_minimizer_prosee/r

I also added a backslash to properly quote the literal dot before pdb, but in this limited context that is probably unimportant.

For completeness, here is the newline variant. Many newcomers are baffled that the shell allows literal newlines in quoted strings, but it can be convenient.

sed -i 's/File//g
    s/MINvac\.pdb//g' /home/kanika/standard_minimizer_prosee/r

Of course, in this limited case, you could also combine everything into one regex:

sed -i 's/\(File\|MINvac\.pdb\)//g' /home/kanika/standard_minimizer_prosee/r

(Some sed dialects will want this without backslashes, and/or offer an option to use extended regular expressions, where they should be omitted. BSD sed, and thus also MacOS sed, demands a mandatory argument to sed -i which can however be empty, like sed -i ''.)

Leave a Comment