Previous Table of Contents Next


CONTROL COMMANDS

case value in
        pattern1 )     commands1 ;;
        pattern2 )     commands2 ;;
        . . .
	patternn )     commandsn ;;
esac

Execute commands associated with the pattern that matches value; patterns can contain the special filename substitution characters like *, ?, and []. Multiple patterns can be given but must be separated with a | character.

for variable in word1 word2 . . . wordn
do
       commands
done

Execute commands once for each word, setting variable to successive words each time.

for variable
do
       commands
done

Execute commands once for each positional parameter, setting variable to successive positional parameters each time.

if command1
then
       commands
fi

Execute commands if command1 returns a zero exit status.

if command1
then
       commands2
else
       commands3
fi

Execute commands2 if commands1 returns a zero exit status, otherwise execute commands3.

if command1
then
       commands
elif command2
then
       commands
. . .
elif commandn
then
       commands
else
       commands
fi

If command1 returns a zero exit status, or command2 returns a zero exit status, or commandn returns a zero exit status, then execute the commands corresponding to the if/elif that returned a zeroexit status. Otherwise, if all the if/elif commands return a non-zeroexit status, execute the commands between else and fi.

until command1
do
       commands
done

Execute commands until command1 returns a zero exit status

while command1
do
       commands
done

Execute commands while command1 returns a zero exit status.

COMMANDS

: null command; returns zero exit status
. file read and execute commands from file in current environment
# begin comments; terminate with a newline
break exit from current for, until, or while loop
break n exit from nth enclosing for, until, or while loop
cd dir change directory to dir. If dir not specified, change directory to $HOME.
echo args display args
eval command evaluate command and execute the result
exec command replace current process with command
exit exit from the current program with the exit status of the last command. If given at the command prompt, terminate the login shell.
exit n exit from the current program with exit status n
export display a list of exported variables
export var export variable var
getopts parse positional parameters and options
hash display a list of hashed commands
hash commands remember locations of commands by putting them in the hash table
hash –r remove all commands from the hash table
hash –r command remove command from the hash table
newgrp change the group-id to the default group-id
newgrp gid change group id to gid
pwd display the pathname of the current directory
read variables read a line from standard input; assign each word on the line to each variable. Words delimited with $IFS.
readonly display a list of readonly variables
readonly var set variable var to be readonly
return exit from a function with return status of the last command
return n exit from a function with return status n
set display a list of current variables and their values
set args set positional parameters to args
set –args set positional parameters that begin with
set [options ] enable/disable options (see OPTIONS section)
shift shift positional parameters once to the left
shift n shift positional parameters n times to the left
test expression evaluate expression (see CONDITIONAL EXPRESSIONS section)
times display total user and system time for current shell and its child processes
trap display list of current traps
trap commands signals execute commands when signals are received
trap "" signals ignore signals
trap signals, trap –signals reset traps to their default values
trap commands 0 execute commands on exit from the shell
type command display information and location for command
ulimit [type] [options] n set a resource limit to n. If n is not given, the specified resource limit is displayed. If no option is given, the file size limit (–f) is displayed. If no type is given, both limits are set, or the soft limit is displayed; type can be:
H hard limit
–S soft limit
and options can be:
–a displays all current resource limits
–c n set core dump size limit to n 512-byte blocks
–d n set data area size limit to n kilobytes
–f n set child process file write limit to n 512-byte blocks (default)
–m n set physical memory size limit to n kilobytes
–s n set stack area size limit to n kilobytes
–t n set process time limit to n seconds
–vn set virtual memory size to n kilobytes
umask display current file creation mask value
umask mask set default file creation mask to octal mask
unset variable remove definition of variable
wait [n] wait for execution (see JOB CONTROL section)


Previous Table of Contents Next
1