SPECIAL PARAMETERS
Some special parameters are automatically set by the Bourne shell, and usually cannot be directly set or modified.
Special Parameters
$n
| positional parameter n
|
$#
| number of positional parameters
|
$@, $*
| all positional parameters
|
"$@"
| same as "$1" "$2" . . . "$n"
|
"$*"
| same as "$1 $2 . . . $n"
|
$?
| exit status of the last command
|
$$
| process id of the current shell
|
$
| current options in effect
|
$!
| process id of the last background command
|
SPECIAL VARIABLES
There are a number of variables provided by the Bourne shell that allow you to customize your working environment. Some are automatically set by the shell, some have a default value if not set, while others have no value unless specifically set.
Special Variables
CDPATH
| search path for cd when not given a full pathname; multiple pathnames are separated with a colon (no default)
|
HOME
| default argument for the cd command; contains the pathname of the home directory
|
IFS
| internal field separator (default space, tab, or newline)
|
LANG
| contains the name of the current locale
|
MAIL
| name of mail file to use if MAILPATH not set
|
MAILCHECK
| specifies how often to check for mail in $MAIL or $MAILPATH. If set to 0, mail is checked before each prompt. (default 600 seconds)
|
MAILPATH
| contains a list of colon-separated file names that are checked for mail. File names can be followed by a "%" and a message to display each time new mail is received in the mail file. (no default)
|
PATH
| search path for commands; multiple pathnames are separated with a colon (default /bin:/usr/bin:)
|
PS1
| primary prompt string (default $, #)
|
PS2
| secondary prompt string (default >)
|
SHACCT
| contains the name of the accounting file that contains accounting records for user shell procedures
|
SHELL
| pathname of the shell
|
TERM
| specifies your terminal type (no default)
|
QUOTING
Quotes are used when assigning values containing whitespace or special characters, to delimit variables, and to assign command output. They also improve readability by separating arguments from commands.
'...'
| remove the special meaning of enclosed characters except '
|
"..."
| remove the special meaning of enclosed characters except $, ', and \
|
\c
| remove the special meaning of character c
|
`command`
| replace with the standard output of command
|
JOB CONTROL
Job control is a process manipulation feature found in the Bourne shell when invoked as jsh. It allows programs to be stopped and restarted, moved between the foreground and background, their processing status to be displayed, and more. When a program is run in the background, a job number and process id are returned.
Job Control Commands
bg [%n]
| put current or stopped job n in the background
|
fg [%n]
| move current or background job n into foreground
|
jobs
| display status of all jobs
|
jobs l
| display status of all jobs and their process ids
|
jobs p
| display process ids of all jobs
|
jobs x command
| replace job n in command with corresponding process group id, then execute command
|
kill [signal] %n
| send specified signal to job n (default 9)
|
stop %n
| stop job n
|
stty []tostop
| allow/prevent background jobs from generating output
|
suspend
| suspend execution of current shell
|
wait
| wait for all background jobs to complete
|
wait %n
| wait for background job n to complete
|
Ctl-z
| stop current job
|
Job Name Format
%%, %+
| current job
|
%n
| job n
|
%
| previous job
|
%string
| job whose name begins with string
|
%?string
| job that matches part or all of string
|
|