bullfighter
bullfighter

Reputation: 427

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

The following code:

for project in $projectlist
do
    echo $project
    ssh user@server 'awk "/^\[EARTH]/{flag=1; next} /\[PROJECT]/{flag=0} flag" /filepath/'${project}'/file |
    sed "s/^/'${project}'\;/g" | sed "s/^/test\;/g" | sed "s/\\/\;/g" | sed "s/\;//9g"' >> "$filepath"/data1.csv;

    ssh user@server 'awk "/\[VALUES]/{flag=1; next} /,0/{flag=0} flag" /filepath/'${project}'/file |
    sed "s/^/'${project}'\;/g" | sed "s/^/test\;/g" | sed "s/\\/\;/g" | sed "s/\"//g"' >> "$filepath"/data2.csv;

done

Gives the following output for each iteration:

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

I have tried several attempts at reformating etc. but always run into this issue. I have escaped the semicolons inside, and none of the $project variables have slashes inside them. Any ideas?

Upvotes: 0

Views: 3677

Answers (1)

user1934428
user1934428

Reputation: 22225

Your sed "s/\\/\;/g" is wrong. You can see the problem when you do just a

sed "s/\\/\;/g" <<<x

You also get a unterminated `s' command.

The double quotes turn on \-escaping, which means that \\ is taken as a single backslash. Hence, sed sees the command s/\/\;/g, which in turn means that it sees only two forward slashes instead of one.

I don't know what you want to achieve, but i.e. sed "s/\\//\;/g" would be syntactically correct.

Upvotes: 1

Related Questions