Dec 112011
 

by
Frank Harris-Smith

Bash has been around since pre-historic times, at least before GNU/Linux’s first release in 1991.

My first personal encounter with Bash was in 1993. This was two years before Microsoft Windows 95 was released and Windows 3.1 was just a bad joke. The Software Development Company I was working for was using SCO Unix running on i486 systems to power Kiosks for displaying, printing and selling sheet music.

My second encounter with Bash was over a decade later was when I first started experimenting with GNU/Linux. I had found a CD in the back of a Linux book with RedHat 7.2 on it– which used an older kernel that had a few missing functions. Like accessing a digital camera, a simple USB Memory Device. So I wrote Bash scripts to mount and access the camera. Then a few more scripts to access a Palm-Pilot like device (My Sony Clie’) and standard USB FlashDrives



Does having a few “encounters” with Bash make me any sort of expert? Answer is no. Honestly, I’m more to solve the problem of the moment type. I’m not a programmer nor do I want to program.

What do I bring to the table when it comes to an article about Bash? My ability to “solve for X” and the research I’ve done to prepare for my next fun project – robotics. To do that I’ll need to use Bash intelligently and to write scrips. Some problems take quite a bit of work to solve, which is where the fun comes in. So I did some Googling and other research.

Okay, enough about me

Is Bash obsolete? Not At all. It may have been around since 1989 but if you want to do something “out of the box”, Bash is probably the sharpest tool in your toolbox. In nearly all GNU/Linux Distros Bash is the default shell. Most Unix Distributions also have Bash as default.

You could use other shells. But why? Bash is the most powerful and flexible. If “necessity is the mother of invention” then since no one has come up with anything better than Bash, I’d guess Bash is as good as it needs to be. Everyone seems happy enough with Bash.

Does your GNU/Linux Distro use Bash?

An easy way to verify your Distro of Linux defaults to Bash is open a terminal Windows. Bash has a unique character prompt, the $. Like this:

bash

Simple enough

The built in man pages of Linux system are an excellent way to jog your memory. East enough to look up the syntax of a command, or a variable’s name, or whatever little detail that you are unsure of. Just type man bash into your terminal.

man bash

Before you go into a frenzied mode of terminal typing, here is a simple list of Bash Key combinations that will make your life easier, plus help prevent Carpal Tunnel Syndrome.

Key combinations in Bash

The Tab Command do a filename completion and is especially nice for navigating directories with long names. You can correct typos with the Left and Right Arrow keys and even go to the beginning or end of a line.

Here is the Official Bash Reference Manual, from gnu.org. Here you will find a comprehensive if somewhat hard to follow Manual, especially if you are new to getting your hands dirty “under the hood”.
Research led me to a couple of decent Bash Tutorials, one of which might be of help to you. The first is more beginner orientated and the second more advanced.

Bash guide for Beginners
Bash guide on Greg’s wiki

Bash has a number of built in commands. Functions that are quite useful in getting your task accomplished. Here is just a taste:

15 Useful Bash Shell Built-in Commands (With Examples)

Linux (and Unix) are text based files that can be used to deal with hardware that doesn’t have Linux drivers or to perform custom functions like controlling a peripheral device, like a Robot or motorized telescope mount. Here are three links that I’ve found to be informative.

Bash scripting Tutorial

Steve Parker’s shell scripting guide

Linux Shell Scripting Tutorial


All this sounds complicated. Far less complicated than it could be if a certain philosophy hadn’t been followed, the Unix/Linux Philosophy

  • Do one thing and do it well – Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.
  • Everything is file – Ease of use and security is offered by treating hardware as a file.
  • Small is beautiful.
  • Store data and configuration in flat text files – Text file is a universal interface. Easy to create, backup and move to another system.
  • Use shell scripts to increase leverage and portability – Use shell script to automate common tasks across various UNIX / Linux installations.
  • Chain programs together to complete complex task – Use shell pipes and filters to chain small utilities that perform one task at time.
  • Choose portability over efficiency.
  • And:

kiss

In comparison the people at Redmond, Washington on the US of A put all their configuration data into a large database called the registry. Very complex and very hard to understand. They even call them “hives”, kind of appropriate considering needing to edit the registry feels like getting too up close and personal with a wasp nest.

I much prefer Linux’s simplicity

Popular Posts:

Flattr this!

  8 Responses to “Bash and I – The Bourne-Again SHell”

  1. It’s not “Me and Bash”.

    It is “Bash and I”.

    Us techheads wouldn’t be caught dead posting:
    $ “hello world” echo

    So why is acceptable to mangle the English language? Hmmm…

    • No, it’s not acceptable, i agree.
      My fault.

      • Frank, you were bulldozed by Smithy, who spoke too soon You’re doing fine.

        “Me and BASH” is awkward; “BASH and Me” would be better. (As in, “The Story of BASH and Me”.)

        “BASH and I”, however, is Just Plain Wrong, except with a following verb. (Simple usage test: Delete the noun, and listen. Here, it’s about “Me”, not “I”. “The Story of I”? You’ve gotta be kidding! 🙂

        More importantly: Less than perfect English had better be acceptable in on-line writing, if we’re to get the benefit of good information from other than polished grammatarians.

        Most importantly: Thank you for a very good and very readable article!

        Cheers from
        –Dick

  2. Smithy, isn’t it : “So why is IT acceptable to mangle the English language? Hmmm…” 🙂

  3. When I see mangled sentences like, “An easy way to verify your Distro of Linux defaults to Bash is open a terminal Windows.” it’s hard for me to conclude anything except that the author is indifferent to the quality of the article. The title grammar is only the first in an embarrassing series of sloppy errors. I’m sorry to report that I did not even read through to the end, so if this article suddenly became readable and interesting I will have missed it… >-/

  4. Never saw “bash” anywhere on any unix since 1985 ’till linux got into full swing around 2000. NO, MOST Unix’es (aix, hpux, at&t, sco,irix,etc) DO NOT DEFAULT TO BASH, they use sh, csh, ksh, ANYthing but bash. Even SCO never went that way, although you could likely get it, but I’ll bet what you actually used was sh….

    These days you can likely get a copy for most, but it’s certainly not the default except on linux…

  5. Nevermind the English lessons…

    I started using Bash about a century ago when my company moved from HP-1000 systems to HP-9000 running HP-UX. Now-a-days, though, I have moved to Zsh. If Bash has everything, Zsh has everything^2.

Leave a Reply to linuxari Cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*