Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

search and replace recursive directories modifier inquiry

by stretch (Novice)
on Oct 25, 2002 at 22:18 UTC ( [id://208165]=perlquestion: print w/replies, xml ) Need Help??

stretch has asked for the wisdom of the Perl Monks concerning the following question:

Hail,
I want the following to search thru recursive subdirectories for *.html files.
============== perl -pi.old -e "s|../forum_idx.pl|../cgi-bin/forum_idx.pl|g" *.htm +l ==============

What modifier do I use to search subdirectories?
thanks, Stretch

Replies are listed 'Best First'.
Re: search and replace recursive directories modifier inquiry
by penguinfuz (Pilgrim) on Oct 26, 2002 at 00:01 UTC
    I agree with Enlil, you really should have a look at File::Find, but a quick oneliner (on a Unix/Linux machine) could be:

    find . -name "*.html" | xargs perl -pi -e s/oldstring/newstring/g
Re: search and replace recursive directories modifier inquiry
by Enlil (Parson) on Oct 25, 2002 at 22:27 UTC
    If you are on a unix system you might try a combo of find, xargs and your one liner. I would look into using the File::Find module and writing a slightly longer script instead of a one liner.

    -enlil

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://208165]
Approved by penguinfuz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2024-04-25 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found