Learn the Bash shell.

By | August 17, 2014

The poor Bash shell script. It gets lost in the flood of all the glitzy language wars, Python vs Ruby vs Perl vs Javascript… the list goes on and on, with new contenders seemingly rising from nowhere to get in the fight for developers attentions. Seldom do I hear anyone stick up for the poor little Bash script. Seems like everyone likes the glitzier languages more. There are books galore for all the “big guns” of the programming world, and more of those seem to pop up everyday, seldom do I see a new book for Bash or Bash scripting show up anywhere.

I know I’m a bit partial to Bash, being a Systems Administrator, I use it daily. Almost a decade ago, I started a website http://bashscripts.org, because I really enjoyed the language and there seemed to be no end to all the cool stuff it could do. So, I’m here to stick up for this under rated programming language. Yes, some of you will look down on me for calling it that. But it is of course a programming language. Concise Encyclopedia defines a programming language as a: “Language in which a computer programmer writes instructions for a computer to execute.” So, you see, you are programming, regardless of how others try to redefine it. Don’t let anyone kid you, you ARE programming. Some people prefer to call it “scripting”. Like that’s a bad thing, and beneath them. HA. They know not what they are saying. Learn the Bash shell and the gnu tools that most distribution install by default, and you will always have a Swiss army knife of knowledge for working with your operating system. Be careful, or you might also get introduced to that nasty Mr. Awk and Ms. Sed as well. If your new to Linux, by all means, make learning Bash scripting one of the top priorities on your list of things to learn.

When writing shell scripts, you will probably also learn to include outside programs, like curl, ssh, and other useful tools. Learn about all these cool tools that people before you have built and made available for you. Bash is the super-glue that can bind these powerful programs together to build even more powerful programs. Not so far removed or different from say, Perl modules, or Python modules. If you need to, you can even include entire Perl or Python programs IN your shell script. I often see opinions like, “Bash is only good for those one liners, small stuff. Anything very complicated should use (insert language and flame war here)”. They simply haven’t seen any of my 2,000+ line Bash scripts, or what they can do. One of those “scripts” happens to be a cluster controller for 4 Oracle T4’s running Solaris each with multiple zones that could turn on and off those zones and move them from machine to machine and could give you a representation of what each had running on it, in color no less. One of the other administrators where I work, demonstrated it to some Oracle engineers that were visiting one day, they gave it the thumbs up. Please don’t let anyone fool you into thinking that learning the Bash shell, and Bash shell scripting, is a waste of time.