user3534203
user3534203

Reputation: 33

substitution of a word with two words and a space using sed

I am trying to substitute a word using 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 populates:

sed: -e expression #1, char 17: unterminated `s' command

Any help would be of great appreciation. I've searched everywhere without any clarity.

Upvotes: 3

Views: 3999

Answers (1)

jaypal singh
jaypal singh

Reputation: 77185

You are missing quotes. You need to wrap the substitution portion inside quotes like:

sed 's/TITLE/New Title/' old.txt > new.txt

If you are using variables as part of substitution, you'll need to use double quotes " instead of single quotes ' to allow variables to interpolate.

Take a look at sed man page and explore -i option which allows you to make in-place changes.

Upvotes: 4

Related Questions