Press "Enter" to skip to content

Day: 12 May 2003

Guess That Movie: Scores So Far VI

Another nine images, and another update of the scoreboard and Kymberlie is still in the lead with 2190 points now (so she’s entitled to another prize, but since she’s currently on vacation/holiday she won’t be able to claim it – plus it gives the rest of you a chance to earn some valuable points! LD is still 55 points off the “500 points claim point”, Super Beastmaster is just 120 points behind and “the only other person apart from Kymberlie to win points in the last set of rounds” – Dr G – needs 260 points.

Admittedly, Kymberlie did get a boost of 200 points for round 52: Loser as it had been over 6 days since I had posted it and there were no correct guesses – therefore I had it on “bonus points round” for a day and she just waltzed in and won the extra 200 points. Drat.

Anyway, Good luck and be ready for round 55…

Techy: Single Line Multiple File Search And Replace

Whilst performing the server upgrades, Ensim Pro died and crashed the server forcing us to roll back to plain old Ensim on the Red Hat Linux box. After we had done that, we then had to restore all the customer data and I noticed a slight inconsistency in the data: for some reason, all the backup files had the wrong IP address stored in them! So after the backups were restored, I found the Apache virtual conf folder (/etc/httpd/conf/virtual) and executed the following command at the Linux shell prompt (as root):

/usr/bin/perl -pi -e ‘s/old_IP_address/new_IP_address/g’ *

This practically is a single line multiple file search and replace function and it works as follows:

  • usr/bin/perl start the Perl interpreter (the language this script is written in)
  • -p instruct perl to loop/repeat around the following instructions
  • i edit the specified files in place (i.e. alter the stated files)
  • -e “what follows is a single line command”
  • ‘s/old_IP_address/new_IP_address/g’ a Perl regular expression to subsitute the text old_IP_address with the text new_IP_address on a global basis (if you omit the ‘g’ it will only replace the first occurrence of the old_IP_address found in each file). Change to /gi for a global, case insensitive search if you require
  • * change files matching this wildcard (*=every file and extension: you could use “*.html” just to change files ending in .html if you wanted)

I hope this little script comes in handy to someone else, but I still wish that I hadn’t needed to work out how to do it 🙁