Re: need help with sed problem
on 19:08 Fri 18 Mar, Joao Ferreira gmail (firstname.lastname@example.org) wrote:
> On Fri, 2011-03-18 at 18:59 +0100, Andrej Kacian wrote:
> > On Fri, 18 Mar 2011 17:46:04 +0000
> > Joao Ferreira gmail <email@example.com> wrote:
> > >jmf@squeeje:~$ sed s/bbbb.*/bbbb:$PWD/ text.txt
> > >sed: -e expression #1, char 16: unknown option to `s'
> > Hello,
> > this is because $PWD gets expanded by shell before sed gets called, so what
> > actually gets executed is:
> > sed s/bbb.*/bbbb:/home/myself/ text.txt
> > ...which is obviously syntactically incorrect.
> > To get result you want, try using different separator character than /, for
> > example the comma, or underscore:
> > $ sed s,bbb.*,bbbb:$PWD, text.txt
> > $ sed s_bbb.*_bbbb:$PWD_ text.txt
> Thanks a lot... I did not know that was possible...
> I used the # separator. Worked just fine
Please note that '#' is a valid filesystem name character.
There are relatively few values which are safely excludable. In your
case this shouldn't be a problem, but in the general case (I'm working
on a script that needs to do path parsing) it's a bit of a pain.
Dr. Ed Morbius, Chief Scientist / |
Robot Wrangler / Staff Psychologist | When you seek unlimited power
Krell Power Systems Unlimited | Go to Krell!