A while loop allows execution of a code block an arbitrary number of times until a condition is met. This tech-recipe describes the while loop syntax for the various Bourne shells (sh, ksh, bash, zsh, etc.) and provides examples.
Common practice for inputing passwords is to read the text without displaying it on the screen. The UNIX Bourne shell does not have this functionality as a command, but a combination of commands will make this work.
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.
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.).
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.
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.
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.