Linux variables have the prefix $. Variables that will be useful in shell scripting are listed below.
$$ Process ID number of the shell in execution
$? Variable indicating Exit status (from the last command that got executed)
$* Entire argument string in the command line (excluding script name)
$# Number of arguments in the command line (not counting the shell script name)
To access arguments passed to a script, following variables are used.
$0 Name of the program (with entire path)
$1 First argument passed in the command line
$2 Second argument passed in the command line
$n Nth argument passed in the command line
To move or shift to a specified argument in the list of arguments, "shift" command is used. For example, to shift 1 argument just type "
shift" or "
shift 1" and to shift to the third argument in the list type "
shift 2".
(more…)