The ‘Bourne shell scripting’ Archives
Posted by

Bourne/Bash Shell Script for Loop Syntax

A for loop allows a program to iterate over a set of values. For loops in a Bourne shell script (sh, ksh, bash, zsh, etc.) are a useful means of iterating through files or other lists. This tech-recipe describes the for loop syntax and provides some examples.

Posted by

Bourne/bash shell scripts: case statement

The case statement is an elegant replacement for if/then/else if/else statements when making numerous comparisons. This recipe describes the case statement syntax for the Bourne shells (sh, ksh, bash, zsh, etc.).

Posted by

Bourne/bash shell scripts: if statement syntax

Conditional expressions give programs life. The ability to branch makes shell scripts powerful. This recipe shows the basic if then else structure for sh, ksh, bash, zsh, etc.

Posted by

Determine if a file is readable by current Bourne shell script user

A well contructed shell script, like any good program, should handle error conditions gracefully. Checking if a file is readable before attempting to read it allows a script to branch instead of abort or display an error message.

Posted by

Determine if a file is writable by a Bourne script user

From a Bourne shell script (sh, ksh, bash, …), it is possible to test if a file exists and is writable by the user running the script.