[sword-devel] Automated Shell Script

Graham Daley sword-devel@crosswire.org
Thu, 16 Nov 2000 17:44:30 +0800


Hi Jonathan,

You wrote:
> From: BJW7TOAEM@aol.com
> Date: Thu, 16 Nov 2000 04:17:57 EST
> Subject: [sword-devel] Automated Shell Script
> To: Sword-devel@crosswire.org
> 
> Hey Everyone,
> 
>        I have a question for the Linux guys on this list. I am
> trying to find 
> a way to easily change the same string of text in a number of
> different 
> files. This is for the Sword Copyright Website, I have about 7
> or so HTML 
> files in a directory on my computer that runs Linux, I would
> like to be able 
> to execute a shell script or whatever works so I can change a
> string of text 
> in each file. Just for an example so you really know what I
> mean:
> 
> I want to change 'the sun is green' which is a string of text
> in all 8 files, 
> to 'the sun is yellow'. How do I do this easily and automated?
> 

Just type this at the command prompt, all on one line:

grep -l "the sun is green" *.html|xargs perl -p -i -e s/"the sun is green"/"the sun is yellow"/g


Cheers,

Graham.


> Thanks for your time and keep the feedback about the site
> coming!
> 
> -Jonathan
> BJW7TOAEM@aol.com