Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Replace across files (extreme newbie)

by plaid (Chaplain)
on May 23, 2000 at 21:44 UTC ( #14416=note: print w/replies, xml ) Need Help??


in reply to Replace across files (extreme newbie)

If you're on a unix machine, the most fun way to do it would be with something like:
find . -type f -exec perl -pi -e "s/string x/string y/g" {} \;
This will find all files, starting in the current directory, and do the replacement intended. If you do not have access to the find command, you're probably going to want to look at File::Find, as it's the standard perl module to handle recursively finding files, and letting you perform some editting on each.

Replies are listed 'Best First'.
RE: Re: Replace across files (extreme newbie)
by takshaka (Friar) on May 23, 2000 at 23:21 UTC
    The File::Find version would be something like this. perl -MFile::Find -pi -e 'BEGIN {find sub {-f && push @ARGV, $File::Find::name}, "."} s/string x/string y/g'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2022-05-29 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (101 votes). Check out past polls.

    Notices?