OK, here's the code, followed by the explanation...
#!/usr/bin/perl -pi $_ =~ s/sometext/someothertext/mg;
Yeah, that's the whole script. The secret is in the -pi. Check out the perldoc perl pages for more information - this form replaces the page entriley. You can also set it so perl writes a backup file as it goes too. To use the script, just do a find exec, like so:
Believe me, this has been a lifesaver. Like moving netscape server instances between servers so you don't have to retweak....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need to change, oh, every file at once?
by BazB (Priest) on Jan 22, 2002 at 04:27 UTC | |
|
Re: Need to change, oh, every file at once?
by ariels (Curate) on Jan 22, 2002 at 12:49 UTC | |
by belg4mit (Prior) on Jan 22, 2002 at 12:55 UTC | |
|
Re: Need to change, oh, every file at once?
by belg4mit (Prior) on Jan 22, 2002 at 04:50 UTC | |
|
Re: Need to change, oh, every file at once?
by sheriff (Sexton) on Jan 25, 2002 at 19:45 UTC | |
by z3d (Scribe) on Feb 02, 2002 at 14:12 UTC |