sed: -e expression #1, char 69: unknown command: `0' - bash

I tried using the following sed command to replace a line in the file that I am reading .
sed -i "/$line/c\\${linerep}" "$1"
where $i is the input file where the lines are to be replaced.
I get the following error when I run the script:
sed: -e expression #1, char 65: unknown command: `0'
sed: -e expression #1, char 69: unknown command: `0'
Please tell me what changes should i make in the sed command?
Is there any other way apart from sed to do the same operation?

Related

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

I have the following shellscript
for i in {1..15..1}
do
sed -i 's/r2.chk/r'$i'.chk' ./ex${i}/r2.gjf
done
which associates to r2.gjf in /ex1, /ex2, etc, it has a line includes r2.chk.
When I run ./sed.sh, I got
sed: -e expression #1, char 15: unterminated `s' command
I found many similar questions on stackoverflow. But, still unsure what's my problem here :(
When I run ./sed.sh, I got sed: -e expression #1, char 15: unterminated `s' command
So terminate the s command - it's missing the /.
sed 's/r2.chk/r'$i'.chk/'
^ - here

sed to insert data in file after a pattern

I have an xml file and trying to append a shell variable contents into the file using sed. The below command works fine but when I use it in a script, it gives me below error. Any suggestions please
sed: -e expression #1, char 66: unknown command: `<'
REQUEST="<abc>abc</abc>\n<xyz>xyz</xyz>"
sed -i "/<NAME>/ i $REQUEST" file.xml
file.xml:
<abc>abc</abc>
<xyz>xyz</xyz>
<NAME>

sed unix error: unterminated 's' command

Executing this command:
sed -e 's/á/\á/g' ./source_file > ./destiny_file
Shows this error:
sed: -e expression #1, char 14: unterminated `s' command
Sentence is a part of an .sh file.
I had tried on several shells: sh/bash/sch
And the result is the same.
The solution was to codify "á" as "xE1":
sed -e 's/\xE1/\&#225\x3B/g'
This works ok!

bash sed: -e expression #1, char 21: number option to `s' command may not be zero

I want to rewrite a line in a conf file. The text that should be put on line 88 is: auth 0.0.0.0/0 - -
My command is :
sed -i '88s/.*/auth 0.0.0.0/0 - -/' /etc/opt/ss5/ss5.conf
But I'm getting an error
sed: -e expression #1, char 21: number option to `s' command may not be zero
How can I solve this issue ?
It is because the text you try to inject contains / which is used by sed as a separator.
You need either to escape this slash , or to use a different sed separator. Sed can accept any character as separator, i.e #.
sed -i '88s/.*/auth 0.0.0.0\/0 - -/' /etc/opt/ss5/ss5.conf
#OR
sed -i '88s#.*#auth 0.0.0.0/0 - -#' /etc/opt/ss5/ss5.conf

Error with sed unterminated s command in bash

I'm having a problem with using sed in a bash script.
Here is the line:
sed -i "s/"$name"/"$input"/g" ~/input.script
I'm getting this error:
sed: -e expression #1, char 24: unterminated `s' command
Weirdly enough it was working in an earlier version of my code. I've been trouble shooting but I cannot find a solution.
You don't need nested quotes. Also, try changing the delimeter:
sed -i "s#$name#$input#g" ~/input.script

Resources