Sed command: unterminated 's command

I execute the sed command

sed -i s/abc=.*$/abc=def ghi/g hpq_sf_attach_wf_param.txt

and this gave me an error:

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

I noticed that this is due to the space between defand ghi. Any idea how to fix this?

+3
source share
2 answers

You need to use quotation to protect special characters, including spaces, $and *.

sed -i 's/abc=.*$/abc=def ghi/g' hpq_sf_attach_wf_param.txt
+11
source

so for the hickosaurs it was right. The reason you have a problem is because it should be double quotes for wildcards, since with single quotes it takes them as alphabetic characters, and not for the value you want.

sed -i "s/abc=.*$/abc=def ghi/g" hpq_sf_attach_wf_param.txt

, "def" "ghi" , "\" .

sed -i "s/abc =. * $/abc = def\ghi/g" hpq_sf_attach_wf_param.txt

+1

All Articles