Use sed to replace one word with two words and a space
I’m trying to replace a word that uses sed with two words. For example I’m using:
sed s/TITLE/New Title/ old.txt > new.txt
However, when I run the command, the following is generated:
sed: -e expression #1, char 17: unterminated `s' command
Any help would be appreciated. I searched everywhere and it was not clear.
You are missing quotation marks. You need to enclose the replacement in quotation marks, for example:
sed 's/TITLE/New Title/' old.txt > new.txt
If you use
a variable as part of the substitution, you need to use double quotes
instead of single quotes
' to allow interpolation of the variable.
sed man page and explore the -i option, which allows you to make