UNIX shell scripting tutorials

Bourne/bash shell script functions

Contributed by Rex on August 5, 2004 under Bourne shell scripting

Writing functions can greatly simplify a program. If a chunk of code is used multiple times in different parts of a script, the code can be enclosed within a function and run using only the function name.

Comments
 

Bourne/bash shell script: while loop syntax

Contributed by Rex on January 9, 2004 under Bourne shell scripting

A while loop allows execution of a code block an arbitrary number of times until a condition is met. This recipe describes the while loop syntax for the various Bourne shells (sh, ksh, bash, zsh, etc.) and provides examples.

Comments
 

csh/C shell scripts: for loop syntax

Contributed by Rex on under csh shell scripting

A for loop allows a program to iterate over a set of values. For loops in a C shell script are a useful means of iterating through files or other lists. This recipe describes the for loop syntax and provides some examples.

Comments
 

csh/C shell scripts: if statement syntax

Contributed by Rex on under csh shell scripting

Conditional expressions give programs life. The ability to branch makes shell scripts powerful. This recipe shows the basic if then else structure for csh, the C shell.

Comments
 

Hide password entry in Bourne/bash shell script

Contributed by Rex on December 15, 2003 under Bourne shell scripting

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.

Comments
 

Bourne/bash shell script for loop syntax

Contributed by Rex on October 29, 2003 under Bourne shell scripting

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 recipe describes the for loop syntax and provides some examples.

Comments
 

Bourne/bash shell scripts: case statement

Contributed by Rex on October 22, 2003 under Bourne shell scripting

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.).

Comments
 

Bourne/bash shell scripts: string comparison

Contributed by Rex on October 21, 2003 under Bourne shell scripting

Comments