[ale] find/replace ever instance of X with Y in *

Jason Day jasonday at worldnet.att.net
Tue Jan 23 09:33:36 EST 2007


On Mon, Jan 22, 2007 at 06:28:58PM -0500, Jim Popovitch wrote:
> I periodically need a utility to change multiple instances of X with Y
> in files Z.  I know that combinations of awk/sed/grep can do some of
> this, but is there a way with one tool to do this?

perl -p -i -e 's/X/Y/g' Z

Z can be a single filename, a list of filenames, a glob, or program
output.  E.g.:

perl -p -i -e 's/foo/bar/g' `find . -name \*.html`

HTH,
Jason
-- 
Jason Day                                       jasonday at
http://jasonday.home.att.net                    worldnet dot att dot net
 
"Of course I'm paranoid, everyone is trying to kill me."
    -- Weyoun-6, Star Trek: Deep Space 9



More information about the Ale mailing list