[wellylug] perl recursive text search and replace
Sam Cannell
sam.cannell at gmail.com
Fri Aug 20 10:38:33 NZST 2004
If, when you call Perl like that, it can accept more than one filename
per invocation (ie perl <arguments> file1 file2 file3) then you can
do:
find /path/to/targetdir -type f | xargs perl -w -pi -e "s/oldinfo/newinfo/g;"
If it can only accept one filename at a time:
find /path/to/targetdir -type f -exec perl -w -pi -e
"s/oldinfo/newinfo/g;" {} \;
I believe that's the right syntax .. I haven't got the find manpage
handy though so I'm not 100% sure.
Sam
On Fri, 20 Aug 2004 10:10:09 +1200, Mark Signal <mark at databackup.co.nz> 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
>
> --
> Wellington Linux Users Group Mailing List: wellylug at lists.naos.co.nz
> To Leave: http://lists.naos.co.nz/mailman/listinfo/wellylug
>
More information about the wellylug
mailing list