Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Replace across files (extreme newbie)

by plaid (Chaplain)
on May 23, 2000 at 21:44 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-25 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found