Reputation: 1401
I have a need to globally replace the pattern \'
with \ '
(\[space]'
) in a file.
I am trying the following sed command:
sed 's/\\\'/\\ \'/g' »In-file« > »Out-file«
but I am getting the following error:
sed: -e expression #1, char 7: unterminated `s' command
What is the right way to invoke sed in this case?
Upvotes: 1
Views: 96
Reputation: 58371
This might work for you (GNU sed):
sed 's/\\'\''/\\ '\''/g' fileIn > fileOut
Or:
sed "s/\\\'/\\\ '/g" fileIn > fileOut
The first solution punches a hole into the shell and retrieves a quoted single quote, whereas the second surrounds the sed script by double quotes. In both cases back slashes need to be quoted by a back slash.
Upvotes: 4