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

Re: [Sheflug] replacing strings in multiple files.



Richard Lowe writes:
 > * Richard Lowe (richlowe [at] btinternet.com) wrote:

 > > * Barrie Bremner (baz [at] barriebremner.com) wrote:

 > > > Is there an easy way (script preferably) that can grep out my old
 > > > address string and replace it with the new one?

 > > very very slightly tested (-i will make backups, but i suggest you so it
 > > anway).
 > > 
 > > for i in *.html; do perl -wpi.bak -e 's/old email/new email/g' $i; done
 > > 
 > > 
 > 
 > I dont know how that loop crept in there, I blame the fact its late.
 > 
 > perl -wpi.bak -e 's/old email/new email/g' *

for i in *.html;
do perl -wpi.bak -e 's/oldusr\@olddomain/newusr\ [at] newdomain/g' $i;
done

Seems to do the trick. Backups an' all!

I need to learn perl.
It was clever even enough to tell me to escape the  [at] 's  - I like that.

I know nothing of the syntax - but you mention a while loop - the $i I
assume.

I am right in saying * is for all cases whereas $i would be once for
each html file?

Baz.

-- 
Barrie J. Bremner

email: baz [at] barriebremner.com | OpenPGP ID: 5164F553

http://barriebremner.com/
[Contact information available at website]

   "Linux? Is that some kind of MacOS?"
      -- BT technical support

---------------------------------------------------------------------
Sheffield Linux User's Group - http://www.sheflug.co.uk
To unsubscribe from this list send mail to
- <sheflug-request [at] vuw.ac.nz> - with the word 
 "unsubscribe" in the body of the message. 

  GNU the choice of a complete generation.