sed unix error: unterminated 's' command - bash

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!

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: -e expression #1, char 69: unknown command: `0'

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?

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

sed behavior on cygwin inconsistent

i have been facing an issue with a certain sed expression working on one windows system and breaking on other. The shell script is being run on cygwin, where the cygwin and sed versions are identical.
expression:
url=$(echo ${!1} | sed 's/{/\\\{/g'); \
error on the system is :
Error: /usr/bin/sed: -e expression #1, char 2: unterminated `s' command
So when i use it by escaping the braces it works:
url=$(echo ${!1} | sed 's/\{/\\\{/g'); \
But the breaks on the other with error saying:
sed: -e expression #1, char 11: Invalid preceding regular expression
Please help .. stuck with this for some time. Please let me know if you need more details.
for a substitution by \{
echo ${!1} | sed -e 's/{/\\{/g'
or by \\{
echo ${!1} | sed -e 's/{/\\\\{/g')
3 \ and no explicit -e are certainly the problem.
Info: No error with your code on my cygwin (usinf a direct string in place of ${!1}
If you escape the first {, sed is waiting for a number of occurence regex and an closing brace (ex: \{1,\})

using sed with local variables that have /

I'm trying to make the sed command replace these:
CURRENT_TOMCAT=/opt/tomcat/lib
NEW_TOMCAT=/usr/tomcat/lib
sed -i "s/$CURRENT_TOMCAT/$NEW_TOMCAT/" tomcat.env
I've tried a bunch of combinations with no success, sometimes getting the unknown option to `s' error, sometimes getting no errors, but no changes are made
The line I that needs to be change looks like this:
TOMCAT_LIB=/opt/tomcat/lib; export TOMCAT_LIB
Try changing the delimiter to another one not contained in your strings. For example, #:
CURRENT_TOMCAT=/opt/tomcat/lib
NEW_TOMCAT=/usr/tomcat/lib
sed -i "s#$CURRENT_TOMCAT#$NEW_TOMCAT#" tomcat.env
^ ^ ^
Test
$ cat a
hello/how are you?
$ old="hello/how"
$ new="bye/how"
$ sed "s/$old/$new/" a
sed: -e expression #1, char 13: unknown option to `s' <---- meeec
$ sed "s#$old#$new#" a
bye/how are you? <---- successful!

Resources