I run below sed command
sed -i s/abc=.*$/abc=def ghi/g hpq_sf_attach_wf_param.txt
and it gave me error:
sed: -e expression #1, char 17: unterminated `s' command
I noticed it is due to space in between of def
and ghi
.
Any idea how to fix it?
In some versions of sed, the expression must be preceded by -e to indicate that an expression follows. The s stands for substitute, while the g stands for global, which means that all matching occurrences in the line would be replaced.
Find and replace text within a file using sed command Use Stream EDitor (sed) as follows: sed -i 's/old-text/new-text/g' input.txt. The s is the substitute command of sed for find and replace. It tells sed to find all occurrences of 'old-text' and replace with 'new-text' in a file named input.txt.
env | sed '/^#/ d' | sed '/^$/ d' Concatenate FILE(s), or standard input, to standard output. With no FILE, or when FILE is -, read standard input.
Use single quotes for sed and you can get away with two backslashes. echo "sample_input\whatever" | sed 's/\\/\//' Hopefully someone will come up with the correct explanation for this behavior.
You need to use quoting to protect special characters, including spaces, $
, and *
.
sed -i 's/abc=.*$/abc=def ghi/g' hpq_sf_attach_wf_param.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With