What is "$" in Shell scripts
I do keep on getting confused when it comes to shell script with "$" sign.
So finally I thought I should jot it down somewhere.
$# implies number of Arguments provided
E.g. if [[ $# -ne 2 ]]
It means, if the number of arguments passed are less then 2
$? tells the exit status of the last executed command
$@ is all of the parameters passed to the script. For instance, if you call
Also, $@ = $*
$1 implies the first argument passed
$2 imples the second argument passed.
And so on...
So finally I thought I should jot it down somewhere.
$# implies number of Arguments provided
E.g. if [[ $# -ne 2 ]]
It means, if the number of arguments passed are less then 2
$? tells the exit status of the last executed command
$@ is all of the parameters passed to the script. For instance, if you call
./someScript.sh foo bar
then $@
will be equal to foo bar
.Also, $@ = $*
$1 implies the first argument passed
$2 imples the second argument passed.
And so on...
No comments:
Post a Comment