System Variables
It is a predefined variable established whenever the UNIX Operating System was established. It is used to store the system status output that is used for feature or present reference purpose.
$?
It Returns the exit status of the last command executed as a decimal string. Mainly commands return a zero exit status if they finished successfully, other a non-zero exit status is returned. For Testing the value of return codes is dealt with later under if and while commands.
# pwd
/usr/nellaiprakash
# echo $?
0
$#
It Returns the number of positional parameters in decimal. The Positional parameters are elaborately discussed later in this session.
$
It Returns the procedure number of the shell (in decimal). Because process numbers are unique between all existing processes, this string is often used to produce unique temporary file names.
# echo $
786
$!
It Returns the process number of the last process which runs in the background (in decimal).
# echo $!
790
$-
It Returns the current shell flags, like as -x and -v.
A few variables have a special meaning to the shell and should be prevented for common use.