need help with sed problem

Joao Ferreira gmail joao.miguel.c.ferreira at gmail.com
Fri Mar 18 17:47:13 UTC 2011


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 
aaaa
bbbb:/some/wrong/path/
cccc

$ sed s/bbbb.*/bbbb:$TERM/ text.txt
aaaa
bbbb:xterm
cccc

$ sed s/bbbb.*/bbbb:$PWD/ text.txt
sed: -e expression #1, char 16: unknown option to `s'
=====================================

I'd like to have

====================================
aaaa
bbbb:/home/myself
cccc
====================================

Can anyone help ? thanks in advance.

Joao






More information about the ubuntu-users mailing list