Re: When is the next PR update due?



#!/usr/bin/perl -i

$to = pop @ARGV;
$from = pop @ARGV;

while(<>)
{
s/$from/$to/g;
print $_;
}

....be careful with this script. It writes back over top the files
it operates on. Backup your directory tree first:

tar -cvzf saved.tgz your_chosen_directory

or change the first line of the script.
Look at:
#!/usr/bin/perl -i .....the minus i switch (-i)
tells perl to write back over top the files it
operates on (instead of writing to stdout)
If you use -i.bak as the switch,
perl will save all the original copies as file.bak
before changing file.

Another way is to eliminate the -i switch entirely
Then the sh command becomes:

#!/bin/sh
for file in `find . -name "*\.html"`
do
rrepstr $file > /tmp/$file
cp /tmp/$file $file
done

now you have a copy of the original, unchanged file
in /tmp, and the changed file sitting where it was
originally

In another post I showed how to change underscores
to dashes in the file names, rather than the file contents.
That's important too. And trickier.

rrepstr will change any character to any other.
It doesn't have to be underscores and dashes.



.



Relevant Pages