Almost any command-line problem can be solved with scripts that write other scripts

Every so often, I have issues that are more easily solved through the command line rather than through a graphical interface. And almost every time, the task to be done is repetitive, doing the same three or four acts over and over again on a set of files, but having to do it one file at a time. Today was no different.

What I generally end up doing is writing a script that will take a filename, and then run the various operations on it. Generally I can then wrap it in a shell for loop, and the problem is solved. And then other times, I'll write a script that outputs another script instead, so I can make sure it's doing the right thing. This is much more fun, especially if the script that gets output is one that generates yet another script, ad nauseam, until you finally get the one that's executed.

Probably not the most efficient way of doing things, but (for me) very amusing.

Trackback URL for this post:

http://chris.charabaruk.com/trackback/1195
Posted In