Shell What?
Posted by David Corfield
John kindly offered to host the contents of my old blog – The Philosophy of Real Mathematics. They are up already here. Unfortunately, the internal links to others of my pages won’t work. Where for instance they say
http://www.dcorfield.pwp.blueyonder.co.uk/2006/02/articulating-your-program.html,
they need to say
http://math.ucr.edu/home/baez/corfield/2006/02/articulating-your-program.html.
John tells me that something called a shell script might be able to perform the translation. Does anyone have an idea of how this could be achieved?
Posted at October 5, 2009 4:13 PM UTC
Re: Shell What?
I think this command should do the trick on any Unix-like operating system:
find . -name "*.html" -print0 | xargs -n 1 -0 perl -pi'.bak' -e's#http://www\.dcorfield\.pwp\.blueyonder\.co\.uk/#http://math.ucr.edu/home/baez/corfield/#g;'
It goes through every *.html file in the current directory and all sub-directories, replacing the old URL prefix with the new one. It makes backup copies ending in .bak of every file.
But you should still make a separate backup copy of everything before you execute the command!