Re: When is the next PR update due?
- From: darnel <Sandy.Pittendrigh@xxxxxxxxx>
- Date: 18 Apr 2007 02:33:15 -0700
#!/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.
.
- References:
- Re: When is the next PR update due?
- From: Paul B
- Re: When is the next PR update due?
- From: darnel
- Re: When is the next PR update due?
- Prev by Date: Google not indexing pages
- Next by Date: (Job) Search Media Analyst - Microsoft
- Previous by thread: Re: When is the next PR update due?
- Next by thread: Re: When is the next PR update due?
- Index(es):
Relevant Pages
|