need help with sed problem

2011-03-18 Thread Joao Ferreira gmail
Hello all I need to use sed to replace a given line in a text file with the current working directory. But this is getting quite tricky. Problem ilustrated below: $ cat text.txt :/some/wrong/path/ $ sed s/.*/:$TERM/ text.txt :x

Re: need help with sed problem

2011-03-18 Thread Andrej Kacian
On Fri, 18 Mar 2011 17:46:04 + Joao Ferreira gmail wrote: >jmf@squeeje:~$ sed s/.*/:$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.*/:/

Re: need help with sed problem

2011-03-18 Thread Boyd Stephen Smith Jr.
On 2011-03-18 12:59:08 Andrej Kacian wrote: >To get result you want, try using different separator character than /, for >example the comma, or underscore: Colon is also a pretty good choice. While it is allowed in pathnames, it already causes problems. Try adding a directory containing colon t

Re: need help with sed problem

2011-03-18 Thread Joao Ferreira gmail
On Fri, 2011-03-18 at 18:59 +0100, Andrej Kacian wrote: > On Fri, 18 Mar 2011 17:46:04 + > Joao Ferreira gmail wrote: > > >jmf@squeeje:~$ sed s/.*/:$PWD/ text.txt > >sed: -e expression #1, char 16: unknown option to `s' > > Hello, > > this is because $PWD gets expanded by shell befo

Re: need help with sed problem

2011-03-18 Thread Dr. Ed Morbius
on 19:08 Fri 18 Mar, Joao Ferreira gmail (joao.miguel.c.ferre...@gmail.com) wrote: > On Fri, 2011-03-18 at 18:59 +0100, Andrej Kacian wrote: > > On Fri, 18 Mar 2011 17:46:04 + > > Joao Ferreira gmail wrote: > > > > >jmf@squeeje:~$ sed s/.*/:$PWD/ text.txt > > >sed: -e expression #1,

Re: need help with sed problem

2011-03-18 Thread shawn wilson
On Fri, Mar 18, 2011 at 7:05 PM, Dr. Ed Morbius wrote: > on 19:08 Fri 18 Mar, Joao Ferreira gmail (joao.miguel.c.ferre...@gmail.com) > wrote: > > On Fri, 2011-03-18 at 18:59 +0100, Andrej Kacian wrote: > > > On Fri, 18 Mar 2011 17:46:04 + > > > Joao Ferreira gmail wrote: > > Please note that

Re: Re: need help with sed problem

2011-03-19 Thread Clive Standbridge
> i agree with that - the underscore that was used is also valid. you > might look at proper quoting of variables to avoid this. something > like cat text.txt | sed -e 's/bbb.*/:"$PWD"/' > new.txt The output from that, given Joao's original text.txt, is :"$PWD" The reason is t