[Gllug] Quoting within sed

Richard Cohen richard at vmlinuz.org
Mon Aug 4 07:50:16 UTC 2003


On Mon, 4 Aug 2003, Robert Boulter wrote:

> Hi,
>   I am trying to isssue a sed command to globally alter the directory
> structure within a shell script.
>   I have tried all manner of combinations but cannot get round the forward
> quotes on sed i.e.
>
>   $ sed s/usr/usr/cnh/g filename
>   $ message garbled

sed -e "s,usr,usr/cnh,g" < filename

Or some such... the / isn't magic, you can use any character after the s to
start a replacement command...

> Here i am trying to change the directory usr to usr/cnh.  However single or
> double quotes or backslash  does not seem to remove the special meaning the
> forward slash between usr/cnh has for sed,
>   i.e
>   usr'/'cnh
>   usr"/"cnh
>   usr\/cnh
>
>   does not work.  Any suggestions from a struggling beginner would be
> welcome.
> Regards Rob.

Cheers
Richard

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list