If you were alive back when Windows 3.1 was a program that had to be installed over DOS, you probably wrote some batch files in your day. As the desktop marches on, mere users become farther removed from the underlying operating system becoming comfortably insulated with layer upon layer of graphical user interface. There are tasks, however, that are quicker and easier to do with a quick batch file than with any graphical interface. Unattended software installations are definitely one of the more common uses for batch files.

DOS (or whatever Windows is riding on these days) is only moderately powerful. Much more powerful, to the level where they qualify as a full-fledged scripting language, are Linux shell scripts. While the black screen of a Linux box may look much like the same black box of a Windows machine, the shell interpreter running on the Linux computer can do much more than just act as an interface between the OS and the hardware.

There are different command interpreters available for Linux, but one of the most popular is BASH. BASH stands for the Bourne Again Shell which is a play on the fact that it is an improved version of the original Bourne Shell (simply referred to as sh).

Part of the power that BASH brings to the table above anything a DOS batch file can do is largely attributable to the complex structures and conditional loops that a programmer can use in a BASH script. The other part of the power is that *NIX-like tools are historically developed with an efficient ideal. Typical *NIX tools are developed with the philosophy that one tool should do one job and it is up to the programmer to string together multiple tools to achieve powerful results. This development philosophy has provided an environment where the vast, vast majority of tools available on an *NIX system are suited - nay, created - to be called from a script.

*NIX machines all ship with a shell interpreter of some kind and, these days, many also ship with a nice shiny desktop. The presence of this powerful shell right out of the box means that any *NIX-like computer is able to be become more useful and more efficient prior to installing anything else. The only tool required to write complex and power shell scripts is a text editor which also ships with every *NIX-like computer out of the box. That's it - install and go.

The Advanced BASH Scripting Guide is the first place to turn to with questions about the usage or development of BASH and as the page says, the only way to really learn scripting is to write scripts!

Reblog this post [with Zemanta]