I started this post back in 2007, when I found a great tutorial on learning bash scripting. This excellent tutorial, written by Daniel Robbins, the Chief Architect of the Gentoo Project, gives two compelling reasons to learn bash:
1. You are already running it. If you are building web tech, chances are that some machine you use is running bash, even if you feel obliged to work on a Windows laptop like me. On Windows, you can run cygwin, which means your scripts will run locally and on your Linux machine. There are some prickly edges, but mostly you can just pretend it’s all one happy unix-ie OS.
2. You are already using it. Chances are you already know some bash if you’ve spent any time where you needed to work in a unix shell. Through geek social learning, it creeps into your consciousness. Many folks start using bash constructs before they are even understood. Like the archaic symbols of some ancient spell woven in the air, the magic works even if you don’t know what it means. However, if you can be inspired to learn what’s really going on, there is great power in bash scripting.
Of course, the real reason for my strong desire to learn bash scripting that I indulge in every month or so, is that I’ve grown tired of repeating myself. It is an old coder’s adage, that by the time you find yourself doing something a third time, you should automate it. Then you never have to do it again. I’d like it to be as quick to for me to write a bash script as to type the commands into a shell. Right now, it still takes several hours for me to write a script, and I sometimes get stumped.
Since I only script intermittently, I thought I’d record in my blog some of the handy tips I have learned from my colleagues and link them with this post over time, so I can refer back to these little bits of wisdom and perhaps other people can also be inspired.
Bits of Wisdom:
* xargs is your friend