[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: need help with sed problem



On Fri, 18 Mar 2011 17:46:04 +0000
Joao Ferreira gmail <joao.miguel.c.ferreira@gmail.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

-- 
Andrej Kacian


Reply to: