Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
"$" 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
echo $1
echo $2
then, try to execute the file followed by 2 arguments.
$? 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.
Last edited by PenguinPwrdBox; 09-09-2005 at 09:53 PM.
$@ 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
echo We are running as PID: $$
if [ -z $1 ];then
echo Not called with arguments, recalling: $0 ARG1 ARG2 ARG3
$0 ARG1 ARG2 ARG3
else
echo Called with $# arguments:
for arg in $@;do
echo = $arg
done
true
echo true exited: $?
false
echo false exited: $?
fi
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.