System information

An Introduction to Shells in General
Axis Communications AB provides NO support for application development of any kind. The information
here is provided "as is", and there is no guarantee that any of the examples shown will work in your
particular application.
Revision 1.02 October 2002 42
The shell uses the following variables for specific purposes:
SHELL
the path of the current shell
HOME
the default value for the cd(1) command
PATH
the directories to be searched to find commands
IFS
the internal field separators for command strings
PS1
the primary shell prompt
PS2
the secondary shell prompt
There are various forms of substitution on the shell command line:
‘...‘
Command string between back-quotes is replaced by its
output
"..."
Permits variable substitution between quotes
’...’
Inhibits variable substitution between quotes
$VAR
Replaced by contents of variable VAR
${VAR}
Delimits variable VAR from any following string
The expressions below depend on whether or not VAR has ever been set. If VAR has been set, they
give:
${VAR-str}
Replace expression by VAR, else by str
${VAR=str}
Replace expression by VAR, else by str and set VAR to str
${VAR?str}
Replace expression by VAR, else print str and exit shell
${VAR+str}
Replace expression by str, else by null string
If a colon is placed after VAR, the expressions depend on whether or not VAR is currently set and
non-null.
The shell has a number of built-in commands:
:
return true status
.fn
execute shell script fn on current path
break [n]
break from a for,until or while loop; exit n levels
continue [n]
continue a for,until or while loop; resume n:th loop
cd [dir]
change current working directory; move to $HOME
eval cmd
rescan cmd, performing substitutions
eval
rescan the current command line
exec cmd
execute cmd without creating a new process
exec <|>
with no command name, modify shell I/O
exit [n]
exit a shell program, with exit value n
export [var]
export var to shell’s children; list exported variables
pwd
print the name of the current working directory
read var
read a line from stdin and assign to var
readonly [var]
make var read-only; list read-only variables
set -f
set shell flag (+f unsets flag)
set str
set positional parameter to str
set
show the current shell variables
shift
reassign positional parameters (except ${0}) one left
times
print accumulated user and system times for processes