I’m using the following command in the Linux terminal: sed ‘/123/ {igood}’ 123.txt, but it shows sed: -e expression #1, char 0: unmatched ‘{‘.
However, when I use
sed ‘/123/ { i
good
}’ 123.txt
it runs correctly. I suspect that sed cannot recognize the backslash properly within command blocks.
OS rhel8.8
sed (GNU sed) 4.5
I tried running the command in a script, but it still couldn’t recognize the newline escape in the command block.
sed ‘/123/ { i
good
}’ 123.txt
I want to know why it can’t recognize . If I write the command without line breaks, how should I write it?”
the_stars_wy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.