MLUG Bash Scripting Workshop 25/04/08
Prev Index Next

A word on editors, ...and comments too while we're at it.

When you are writing scripts use an editor that has colour highlighting and smart tabs, i.e. automatic indentation. Note in the two screenshots below that different parts of the text are different colours and indentation (tabs) is consistant.

Colours and indentation will help make your script more readible. Also troubleshooting a script is much easier once you get used to the colours as they will change if syntax and command spelling is not correct.

I don't care what editor you use. if you use Linux, you probably appreciate having a choice. I use Midnight Commander's mcedit when I'm working CLI and I use Kate in KDE. It will make life much easier! No flames please!!

The images below are taken from screenshots and are what these two editors look like respectively in Slackware circa 12.0.



Note in the two screen shots that there are lines that begin with a " # ".

If you are completely new to Bash scripting you may not know that the Bash interpreter will ignore anything that follows a # up until the next newline with the exception of the first line of the file if that line begins with a shebang.

Comments are part and parcel of scripting and programing in any language or environment. Comments help both the author and those that come along afterwards to follow what's happening as well as lighten things up with a little humour as can be seen in this script.


Top