Hi Damian,

>       echo "$i" | sed -e 's%[[./*$^\\]%\\&%g' -e 's%.*%/^&:/d%'
...
>       sed: -e expression #1, char 18: unterminated `s' command

It's the first expression which is the problem.

    $ sed -e 's%[[./*$^\\]%\\&%g' </dev/null
    sed: -e expression #1, char 18: unterminated `s' command
    $ sed -e 's%.*%/^&:/d%' </dev/null
    $

That's using the sed 4.7-1 package on Arch Linux.

It's because ‘[’ represents itself inside a character class unless it's
followed by a colon, dot, or equals because then it looks like the start
of a ‘[:digit:]’ or similar.  Re-ordering works:

    $ sed -e 's%[.[/*$^\\]%\&%g' </dev/null
    $

-- 
Cheers, Ralph.

Reply via email to