On Mon, 2007-09-24 at 23:00 +1000, Martin Visser wrote:
> I always find it much safer to use an explicit in-line script idiom
> such as :-
> 
> sed -e 'the-script-i-want-sed-to-run' foo
> 
> The ''s make sure that the shell doesn't get first byte of the cherry 
> 

I kinda tried that, but man sed doesn't indicate the quotes:

[EMAIL PROTECTED]:~/test $ sed -e s/foo/\/bar/g foo
sed: -e expression #1, char 8: unknown option to `s'
[EMAIL PROTECTED]:~/test $ sed -e "s/foo/\/bar/g" foo
/bar is barred

I guess I should have realised. Thanks - all is good now.



> On 9/24/07, david <[EMAIL PROTECTED]> wrote:
>         I want to insert "/" into a substitution.
>         Why am i getting an "unknown option" even though exactly the
>         same
>         construction works if i use it from a script file?
>         
>         [EMAIL PROTECTED]:~/test $ cat > foo 
>         foo is barred                                           # test
>         file
>         [EMAIL PROTECTED]:~/test $ sed s/foo/bar/g foo
>         bar is barred                                           # sed
>         works :)
>         [EMAIL PROTECTED]:~/test $ sed s/foo/\/bar/g foo 
>         sed: -e expression #1, char 8: unknown option to `s'    #
>         ERROR
>         [EMAIL PROTECTED]:~/test $ cat > sedfile
>         s/foo/\/bar/g                                           #
>         script file...
>         [EMAIL PROTECTED]:~/test $ sed -f sedfile foo 
>         /bar is barred                                          # ...
>         works
>         [EMAIL PROTECTED]:~/test $
>         
>         I've noticed the same problem applies to using & in the
>         replacement on
>         the cli. It seems that the replacement part doesn't recognise
>         a 
>         backslash. Have I missed something?
>         
>         --
>         SLUG - Sydney Linux User's Group Mailing List -
>         http://slug.org.au/
>         Subscription info and FAQs:
>         http://slug.org.au/faq/mailinglists.html
> 
> 
> 
> -- 
> Regards, Martin
> 
> Martin Visser

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to