[oclug] ...and speaking of awk...
Ross Jordan
rjordan at blanch.math.uwaterloo.ca
Thu Feb 22 19:11:04 EST 2001
Since most of the given solutions were untested, they most likely
failed due to slight typos. Francis's would've most likely hung
because it is a filter -- i.e. it need to be run ./filter < input > output.
Anyways, I give you a tested (albeit quickly) solution:
cd /path/to/html/files/
for file in `ls *.html`;
do
mv $file $file.bak
sed 's/<a href="http:\/\/.*\/\(.*\)"/<a href="./\1"/g' < $file.bak > $file
done
A quick analysis of diff index.html index.html.bak suggests the script
worked as intended. A link to a directory will become ./
i.e. <a href="http://www.yahoo.com/something/"something> -> <a href="./"something>
-Ross
>
>
> Well, the good news is that that was a great response. Thanks.
>
> The bad news is they all failed. Viz.:
> Dan Cardamore
> Name "main::F" used only once: possible typo at ./change-o.pl line 12.
>
> Tom Goulet:
> bash: file: No such file or directory
> mv: tmpfile: No such file or directory
>
> Francis's hung* and I had to ^C out of it.
>
> Dave O'Neil's had syntax errors.
>
> Adrian's hung*.
>
> I haven't tried Skud's yet. Part of this may be a fsck'd up Perl config.
> More on that later.
>
> To test them all I mkdird a dir with three files respectively containing
> the lines:
>
> qwerqw<a href="http://www.spam.com/fud.html">Read the fud page!</a>qwerqw
> <a href="http://www.spam.com/bar.html">Read the bar pages!</a>qwerqw
> qwerqw<a href="http://www.spam.com/foo.html">Read the foo page!</a>
>
> What I want is to change each of those to e.g. ./fud.html . In the real
> case, the URL is unknown.
>
> Thanks, Dave.
> ____________________________________
> *No off-colour jokes, please. ;)
> --
> PGP Public Key http://www3.sympatico.ca/amoamasam/public-key.txt
> >Are you now, or have you ever been, a user of the Linux operating system?
> _______________________________________________
> oclug mailing list
> oclug at lists.oclug.on.ca
> http://www.oclug.on.ca/mailman/listinfo/oclug
>
> Well, the good news is that that was a great response. Thanks.
>
> The bad news is they all failed. Viz.:
> Dan Cardamore
> Name "main::F" used only once: possible typo at ./change-o.pl line 12.
>
> Tom Goulet:
> bash: file: No such file or directory
> mv: tmpfile: No such file or directory
>
> Francis's hung* and I had to ^C out of it.
>
> Dave O'Neil's had syntax errors.
>
> Adrian's hung*.
>
> I haven't tried Skud's yet. Part of this may be a fsck'd up Perl config.
> More on that later.
>
> To test them all I mkdird a dir with three files respectively containing
> the lines:
>
> qwerqw<a href="http://www.spam.com/fud.html">Read the fud page!</a>qwerqw
> <a href="http://www.spam.com/bar.html">Read the bar pages!</a>qwerqw
> qwerqw<a href="http://www.spam.com/foo.html">Read the foo page!</a>
>
> What I want is to change each of those to e.g. ./fud.html . In the real
> case, the URL is unknown.
>
> Thanks, Dave.
> ____________________________________
> *No off-colour jokes, please. ;)
> --
> PGP Public Key http://www3.sympatico.ca/amoamasam/public-key.txt
> >Are you now, or have you ever been, a user of the Linux operating system?
> _______________________________________________
> oclug mailing list
> oclug at lists.oclug.on.ca
> http://www.oclug.on.ca/mailman/listinfo/oclug
>
More information about the OCLUG
mailing list