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

Re: [SLUG] Re: search and replace



On Wed, 28 Jun 2000, Matthew Dalton wrote:

> 
> Michael Lake wrote:
> > 
> > Dean Hamstead wrote:
> > > Is there a command in vi or somesuch standard cli editor to search and
> > > replace
> > > in my case change all ".org" entries to ".com" in the dns files
> > > im sure awk or seomthing can do it also....
> > 
> > cat your_dns_file | sed 's/\.org/\.com/' > new_dns_file
> > 
> > The \. escapes the dot and the dot is there so that names
> > like www.organ_society.org don't end up as
> > www.coman_society.com
> 
> Um... this example will still get screwed up. The 'org' bit in
> www.organ_socitety.org has a dot before it!

Very good point

In vi

    :g/\.org\>/s//.com/g

In perl

    perl -i -p -e 's#.org(\W)#.com$1#g'

Regards
Peter
----------
Peter Samuel                                peter@nospam.eserv.com.au
Technical Consultant                        or at present:
eServ. Pty Ltd                              Peter.Samuel@nospam.ind.tansu.com.au
Phone: +61 2 9206 3410                      Fax: +61 2 9281 1301

"If you kill all your unhappy customers, you'll only have happy ones left"

--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to slug-request@nospam.slug.org.au with
unsubscribe in the text