[Canberra-pm] SEC: UNCLASSIFIED:-A LITTLE HELP...

Jepri jepri at webone.com.au
Wed Oct 2 08:10:45 CDT 2002


On 2002.10.02 17:43 Michael Still wrote:

> Is it off charter to suggest alternatives in other languages?
> 
> find . -type f -name "*.htm*" -exec "cat {} | sed s/.../.../g >
> {}.new; mv -f {}.new {}"

> Is there a good perl equivalent?

There's a perl command will change the files and leave backups as 
filename.bak  It's not quite what you want, but is handy.

find . -type f -name "*.htm*" | xargs -iXX perl -pe's/.../.../' -i.bak 
XX

Randal Schwartz also has a pure-perl solution that takes me five 
minutes to figure out each time I try to use it:

use File::Find;
my @new_list;
find sub {
   push @new_list, $File::Find::name if --- some criterion here ---;
}, @ARGV;
@ARGV = @new_list;
$^I = ".bak";
while (<>) {
   s/old/new/g;
   print;
}



More information about the Canberra-pm mailing list