Writing shell scripts used to be a major, major pain for me. I remember many frustrating sessions, where I tried to find a misplaced quote or a missing backtick. I cursed shell script and only used it as a last resort.

In those days, I would never, ever have thought, that I would write 100K lines of shell script code for a project and not even mind very much doing so.

The main reason for this change of mind is ShellCheck. Combined with a colorizing syntax highlighter in an editor like Sublime Text ShellCheck makes the previously tedious search for that elusive missing backtick or doublequote super easy, barely an inconvenience:

missingbacktick="`cat foo.txt | sed -e 's/xxx/yyy/g'"

What should be white is now yellow, and I immediately know, that I goofed.

Suddenly other problems come to the forefront. The bash shell is an arcane beast, that has laid out a lot of traps. But with a bit of self discipline and modern coding techniques you can make it a pleasant environment.


The organization is supposed to be logical, so you can read it from start to finish. But it is not a Bash-Scripting Guide to learn shell scripting and it’s not a replacement for the bash manual. Without prior knowledge its probably too dense.