[sword-devel] Automated Shell Script

Kevin Brannen sword-devel@crosswire.org
Thu, 07 Dec 2000 00:29:03 -0600

BJW7TOAEM@aol.com wrote:
> Hey Everyone,
>       A couple weeks ago I sent in a question about how I could replace a
> string of texts in a whole bunch of files at once. I was given the following
> as a way to do it:
> grep -l "the sun is green" *.html|xargs perl -p -i -e s/"the sun is
> green"/"the sun is yellow"/g
> Anyways the problem I found was when I was trying to update a string of
> text:
> Site Updated 11/29/00 to Site Updated 12/6/00 I was unable to do it sense
> the
> back slash is used in the syntax of the command. Is there anyway I can get
> around this so that it just reads it as the character "/" in the file, so
> that I can easy change these values. Thanks for your time.
> -Jonathan
> BJW7TOAEM@aol.com

Yes, Perl allows almost any char in place of the "/", as long as you are
consistent within the same command.  So try:

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

Or use "^", or "!", or whatever.  You really should enclose the entire -e
expression in single quotes if at all possible (to protect it from the shell);
which may allow you to lose the double quotes, unless you are looking for