[Sussex] Find & Replace in lots of small files
Andy Smith
andy at lug.org.uk
Fri May 18 20:36:01 UTC 2007
On Fri, May 18, 2007 at 08:31:41PM +0100, Bob Williams wrote:
> I have about 3000 shell scripts, each of which contains the same error, namely
> a spelling mistake in a path. I am looking for a way to automate the find and
> replace I need to do, and wonder if sed is the tool to use?
sed will work, I still prefer in place editing with perl though:
$ perl -pi.bak -e 's/foo/bar/ list of files
or
$ find /path -name '*foo*' -print0 | xargs -0 perl -pi.bak -e 's/foo/bar/;'
replaces 'foo' with 'bar' in the list of files and saves the
original with a .bak suffix.
Cheers,
Andy
--
http://bitfolk.com/ -- No-nonsense VPS hosting
Encrypted mail welcome - keyid 0x604DE5DB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.lug.org.uk/pipermail/sussex/attachments/20070518/479e16de/attachment.pgp
More information about the Sussex
mailing list