Unix Shell Scripting by Chris F.A. Johnson

My new book, Pro Bash Programming: Scripting the GNU/Linux Shell was published 2009-10-19. I wrote Pro Bash Programming as a tutorial that introduces the shell, and bash specifically, as a programming language. It covers everythying from the traditional first program in any language, "Hello, world!", to shell functions, to reading function keys and the mouse.

The shell referred to in these pages is always a Bourne-type shell; that is, a shell whose syntax is based on the Unix shell introduced by Steven Bourne in 1978 (or thereabouts), with some later improvements. On all Unix systems, a Bourne-type shell can be found in /bin/sh. On most modern systems, this will be somewhat better than the Bourne shell — it will be a POSIX shell. If it is not, there should be a POSIX-compliant shell elsewhere on the system.

A POSIX shell is a Bourne shell with a number of extensions (which are mostly derived from the Korn Shell). The most important ones perform string manipulation and integer arithmetic. In a Bourne shell, arithmetic operations require an external program (e.g., expr, awk or bc) as does finding the length of a string, or cutting a string into pieces. POSIX has $((...)) for integer arithmetic and parameter expansions for string operations.

Generally, scripts and snippets published here are designed to run in a POSIX shell. Some will run in a Bourne shell, and those that will not should not be hard to convert (in the unlikely event that you find it necessary). A few scripts require added extensions found in bash and ksh.

What, no csh?

Powered by WebRing.