what is "$?"
i was reading this tutorial on using modules and one of the examples did this:
Quote:
|
"$" is a character for signing a variable.
In bash shell, "$?" means the arguments that typed after a command. For example: "$1" will get the first argument in the shell command. "$2" will get the second... "$3" will get the third... :) To ensure yourself, try to make a file like this: Code:
#/usr/bin/bash regards ag2uki |
$? is a shell variable that contains the exit code of the last command that you ran. Because your code is 1, that denotes an error. A successful command will exit 0.
Don't let the reply above confuse you. While, in most scripting languages (including bash, which he used in the example) the $1, $2, $3, etc.....are the arguments passed to the bash script - but regardless of the shell - $? is the exit code of the previous command. Perl, for example, does not use $1....$3 - perl uses the builtin variable @ARGV to contain the arguments. That is found in the instructions that you were reading so that you could ensure that the module unloaded. |
thanx :D
|
Quote:
|
Quote:
Also, what is '$@'? I have seen that a couple times and I can't understand the meaning of it. -twantrd |
$@ should be all of the arguments given to the script. Take a look at the "Special Parameters" section of "man bash". Here's a quick example - just save it and run it:
Code:
#!/bin/bash |
Thanks David!
-twantrd |
All times are GMT -5. The time now is 10:13 PM. |