[oclug] ...and speaking of awk...

Kirrily Robert skud at e-smith.com
Thu Feb 22 16:42:07 EST 2001


On Thu, Feb 22, 2001 at 03:09:18PM -0500, Dan Cardamore wrote:
> This is untested, but you can tweak it to get it to work:
> 
> #!/usr/bin/perl -w
> use strict;
> 
> opendir (DIR, '.');
> my @html = readdir(DIR);
> closedir(DIR);
> 
> foreach my $file (@html) {
>   open (FILE, "+<$file") or die "DOH!";
>   my @contents = <FILE>;
>   chomp @contents;
>   seek(F,0,0);  # go the beginning of the file
> 
>   # now do your s///g;
>   foreach my $line (@contents) {
>     $line =~ s/http:\/\/some.url/\./g;
>     print FILE "$line\n";
>   }
>   close(FILE);
> }
> print "This may be longer than a shell script, but Its done anyways :)\n";

Jesus H. Christ!

perl -pi.bak -e 's{http://some\.url/}{./}' *.html

That'll do the replacements and leave .bak files for you.

K.


-- 
Kirrily "Skud" Robert
skud at e-smith.com (work)
skud at infotrope.net (home)



More information about the OCLUG mailing list