Sunday, December 4, 2005

17 days into work as part-time IT executive

There are 5 people working in my company, 3 part-timers and none of the part-timers are looking forward to staying. Other than distance, I don't have any complaints about the job actually. Some of the more interesting things I have learnt on the job are using simple AWK and SED to do some text processing.

sed -i "s/hahaha/hehehe" myfile.txt

This replaces all instances of the string "hahaha" with the string "hehehe". How useful is this?
Well, if I need to fit many webpages into a small webserver, you can use sed to delete all the irrelevant tags (like those that inserted by FrontPage) or comments to squeeze the files into smnaller sizes. Or if you need to add some html into many files that contain the same structured data, this comes in handy as well. For example, this shell script adds a new string tag5 after tag4 for all the htm files in the current directory:

myfiles=`ls|grep "htm$"`; for xfile in $myfiles; do sed -i "s/tag4/tag4;tag5" $xfile; done;

Most people would prefer to use Server Side Includes to avoid such a maintenance nightmare from appearing in the first place, but if you are not allowed to use that then perhaps this is an alternative.

I've always wondered how Windows knew which interface to use in a PC with multiple adapters. Found out you can bind certain protocols to specific network adapters such that it becomes the default interface to be used.

So it's not too bad, at least I'm learning something while doing some mundane jobs like updating catalgoues or dis/assembling PCs.

No comments:

Post a Comment