How to escape single quote in sed?

Quote sed codes with double quotes: $ sed “s/ones/one’s/”<<<“ones thing” one’s thing I don’t like escaping codes with hundreds of backslashes – hurts my eyes. Usually I do in this way: $ sed ‘s/ones/one\x27s/'<<<“ones thing” one’s thing

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 … Read more

sed fails with “unknown option to `s'” error [closed]

The problem is with slashes: your variable contains them and the final command will be something like sed “s/string/path/to/something/g”, containing way too many slashes. Since sed can take any char as delimiter (without having to declare the new delimiter), you can try using another one that doesn’t appear in your replacement string: replacement=”/my/path” sed –expression … Read more