LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What does the $@ represent in a bash script? (https://www.linuxquestions.org/questions/linux-newbie-8/what-does-the-%24%40-represent-in-a-bash-script-607671/)

danielj28 12-18-2007 02:46 PM

What does the $@ represent in a bash script?
 
I'm new to reading (and writing) bash scripts and I can't find any documentation for what the $@ parameter/variable represents and what value it receives. Please advise. Thanks.

pwc101 12-18-2007 03:18 PM

Quote:

Originally Posted by man bash
@ Expands to the positional parameters, starting from one. When the
expansion occurs within double quotes, each parameter expands to a
separate word. That is, "$@" is equivalent to "$1" "$2" ... If
the double-quoted expansion occurs within a word, the expansion of
the first parameter is joined with the beginning part of the orig-
inal word, and the expansion of the last parameter is joined with
the last part of the original word. When there are no positional
parameters, "$@" and $@ expand to nothing (i.e., they are
removed).

It means each argument supplied to the script from the command line:
Code:

pwc101@linux:> ./myscript argument_1 argument_2
$@ represents argument_1 and argument_2 in that example, which can be individually referenced as $1 and $2.

See http://db.ilug-bom.org.in/Documentat...es.html#APPREF for more info.

danielj28 12-18-2007 07:37 PM

Thanks
 
for the help!

PTrenholme 12-18-2007 07:51 PM

On most distributions the info command (in a terminal window) may be used to display information about a command. Did you try info bash?

If you're not familiar with the info command, try info info for an explanation.

chrism01 12-18-2007 11:56 PM

The nice version of the manual: http://www.tldp.org/LDP/abs/html/int...es.html#APPREF


All times are GMT -5. The time now is 11:04 AM.