|
Added this line to prove it changed. Like all of my examples this one is "really dumb": in other words, it tries to show exactly what it needs to, no more and no less. It can be used as a building block for something much more complicated. This particular example could be thought of as "building a database", which you could use to save and retrieve information you need for administration. It comes from this particular problem. Lingtao sent me an email which contains the name and address of each of the machines we will use. I would like to have these in the form of a "character-separated database". I am choosing the "pipe symbol" '|' as the separator (it does not conflict with commas and semicolons and dots and stuff). On the other hand "keeping it in quotes" so the shell does not interpret it as a pipe command will raise h*ll with your life:-. So I need a "little program" to read in the txt file I made from Lingtao's email, which has the name, some space, the address, and create a text file which has address|name as its entries. Then I need a couple of little tiny functions that will produce name from address or address from name. I know I could do it all "in Perl" or in 1000 other languages/ways, and for such a small collection of data it is sort of silly to automate it. Most "old-line" actual Unix admins are comfortable with just "throwing a script together", so this is about the simplest usable example of such a thing I could make. One very frustrating thing about shell scripts is that the syntax is a bit strange at times, and the parser is VERY unforgiving. I tend to write mine in "baby steps" as a result, and test the pieces before writing the whole. |
| zipped source code |
Code linksListings
|