Thursday, September 26, 2013

Raspberry Pi Journal #29

BASH Scripting


As you may know, Python is the officially supported programming language of Raspberry Pi. What you may not know is that the Raspbian shell is bash, Born/Bourne Again Shell. Bash is a more sophisticated version of sh. There is also csh, and other flavor, if you're interested.

That's why, you frequently see "#!" shebang format for script language. That has special meaning to run the program specified and feed it the content of the file. That's right. A Python script is just a program that interprets the file's content. Pretty convenient, eh?

So, what does that have to do with bash? If you're used to Windows shell, probably not much. But if you look at the documentation for bash, man bash, you'll see that it is rather involved.

Shell scripting isn't strictly computer programming, although the nuance may be lost to inexperienced coder. If you know Perl, that language was designed to act as a glue language for various programs. So, the relationship would be bash-perl-program.

And Perl is very convenient to use. I use it a lot in the past. However, sometimes you don't need the full brunt of full-featured scripting language. bash is a viable lightweight alternative.

I'm not that good of a coder with bash. Still, it is something you should learn. There was a job description that says something like:

The applicant must know Unix shell programming, but sufficiently advanced enough to realize that it is not an achievement.

In other words, shell scripting is not a proper computer programming. It is a "convenient" tool.

Let me just point to you a nice resource that I found on the web, and I happily read it. I hope you do too.

http://tille.garrels.be/training/bash/

You need to know Linux already, but for those of you who do, this is a great resource.

No comments:

Post a Comment