I am new to shell scripting. I am using ksh.
I have this particular line in my script which I use to append text in a variable q to the end of a particular line given by the variable a
containing the line number .
sed -i ''$a's@$@'"$q"'@' test.txt
Now the variable q can contain a large amount of text, with all sorts of special characters, such as !@#$%^&*()_+:"<>.,/;'[]= etc etc, no exceptions.
For now, I use a couple of sed commands in my script to remove any ' and " in this text (sed "s/'/ /g" | sed 's/"/ /g'), but still when I execute the above command I get the following error
sed: -e expression #1, char 168: unterminated `s' command
Any sed, awk, perl, suggestions are very much appreciated
$ais here a line number intest.txt?perl -i -pe 's/$/ $./' fileperl -pi -E 'BEGIN {$q = shift; $a = shift} s/$/$q/ if $. == $a' "$q" "$a" test.txt