[wellylug] perl recursive text search and replace

Darryl Hamilton wellylug at addict.net.nz
Fri Aug 20 10:41:16 NZST 2004


I don't think Perl can do that kind of thing in a one-liner, but I'm not 
exactly experienced with it, so I'm probably wrong.

I'd use a 'find -exec' set up to handle the sub directories

find . -name *.txt -type f -exec perl -w -pi -e "s/oldinfo/newinfo/g;" {} \;


Mark Signal wrote:
> I could use a little help here....
> 
> this will replace text within a nominated directory
> 
> perl -w -pi -e "s/oldinfo/newinfo/g;" targetdir/targetfile
> 
> how do I alter it to include all subdirectories?
> 
> cheers
> 
> Mark
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004
> 
> 




More information about the wellylug mailing list