Re: please help: how do I replace words

2002-11-21 Thread Dan Nelson
In the last episode (Nov 21), Norbert Koch said:
> adrian kok <[EMAIL PROTECTED]> writes:
> 
> > I tried:
> >
> > sed -n 's/192.168.0.1/172.16.0.1/w abc.com.tmp'
> > abc.com
> >
> > file abc.com.tmp
> > only shows l line
> > abc.com   172.16.0.1
> > and missing localhost.abc.com 127.0.0.1
> 
> sed 's/192.168.0.1/172.16.0.1/' abc.com > abc.com.tmp

Also note that on FreeBSD 4.7 and newer, you can do an in-place update
of a file with sed if you use the -i flag.

-- 
Dan Nelson
[EMAIL PROTECTED]

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: please help: how do I replace words

2002-11-21 Thread John Von Essen
Use the following with the -e option, not the -n option:

sed -e 's/192.168.0.1/172.16.0.1/g' in-file > out-file

With in-file containing:
abc.com   192.168.0.1
localhost.abc.com 127.0.0.1

And resulting out-file containing:
abc.com   172.16.0.1
localhost.abc.com 127.0.0.1



-John Von Essen


On Thursday, November 21, 2002, at 02:23 PM, adrian kok wrote:


Hi all

I have problem to replace words
from 192.168.0.1 to 172.16.0.1 in file abc.com

file content:
abc.com   192.168.0.1
localhost.abc.com 127.0.0.1

I tried:

sed -n 's/192.168.0.1/172.16.0.1/w abc.com.tmp'
abc.com

file abc.com.tmp
only shows l line
abc.com   172.16.0.1
and missing localhost.abc.com 127.0.0.1



I tried and it is same!
sed -n 's/192.168.0.1/172.16.0.1/gw abc.com.tmp'
abc.com

I can't use perl because the sed is within shell
script

TIA















___
Do You Yahoo!?
Get your free @yahoo.com.hk address at http://mail.english.yahoo.com.hk

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message


Do:




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



Re: please help: how do I replace words

2002-11-21 Thread Norbert Koch
adrian kok <[EMAIL PROTECTED]> writes:

> I tried:
>
> sed -n 's/192.168.0.1/172.16.0.1/w abc.com.tmp'
> abc.com
>
> file abc.com.tmp
> only shows l line
> abc.com   172.16.0.1
> and missing localhost.abc.com 127.0.0.1

sed 's/192.168.0.1/172.16.0.1/' abc.com > abc.com.tmp

norbert.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message



please help: how do I replace words

2002-11-21 Thread adrian kok
Hi all

I have problem to replace words 
from 192.168.0.1 to 172.16.0.1 in file abc.com

file content:
abc.com   192.168.0.1
localhost.abc.com 127.0.0.1

I tried:

sed -n 's/192.168.0.1/172.16.0.1/w abc.com.tmp'
abc.com

file abc.com.tmp
only shows l line
abc.com   172.16.0.1
and missing localhost.abc.com 127.0.0.1



I tried and it is same!
sed -n 's/192.168.0.1/172.16.0.1/gw abc.com.tmp'
abc.com

I can't use perl because the sed is within shell
script

TIA















___
Do You Yahoo!?
Get your free @yahoo.com.hk address at http://mail.english.yahoo.com.hk

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message