Linked Questions

138 votes
4 answers
194k views

What's the difference between $@ and $* [duplicate]

According to this page, $@ and $* do pretty much the same thing: The $@ holds list of all arguments passed to the script. The $* holds list of all arguments passed to the script. After searching ...
spuder's user avatar
  • 18.2k
8 votes
4 answers
23k views

what does $* mean in shell [duplicate]

What does $* mean in shell? I have code two function, run_command and run_test, they are called like this: if [ -n "`echo ${GOAT_COMMANDS} | grep $1`" ]; then run_command $* else run_test $* fi ...
betteroutthanin's user avatar
8 votes
3 answers
2k views

In bash, what is the safest way to pass variables to another program -- $* or $@? [duplicate]

Can someone explain to me in a concise way what the difference between these two vars is? What is the safest way to pass variables to another program? E.g. #! /bin/bash # do stuff # pass ...
Jonathan's user avatar
4 votes
2 answers
38k views

What is the meaning of $* in a shell script? [duplicate]

In a shell script file i saw "$*", what does it mean and when we have to use it?
Saeed Zarinfam's user avatar
2 votes
1 answer
17k views

What is ${@} in bash? [duplicate]

Recently I was learning bash commands in Linux, specifically string manipulation. In that there was a local variable declared to be equal to ${@}. I understand that $n refers to the nth command line ...
Ash Ketchum's user avatar
7 votes
7 answers
396 views

What is the purpose of having two variables ($@,$*) to transmit the arguments of a command into a script? [duplicate]

I have read of the special variables used in a script $@ and $*. As far as I understand, the arguments used while executing the script are stored into two special variables, once all arguments into $@ ...
Abdul Al Hazred's user avatar
3 votes
1 answer
2k views

What is the difference between ${array[*]} and ${array[@]}? When use each one over the other? [duplicate]

With the following code: #! /bin/bash declare -a arr=("element1" "element2" "element3&...
Manuel Jordan's user avatar
1 vote
1 answer
544 views

what does "$@" mean inside a find command [duplicate]

I recently saw a script in which below find command was used: find "$@" -type f -name "*.iso" What does "$@" mean here?
A.K's user avatar
  • 55
0 votes
2 answers
597 views

Different behaviour of eval " command \"$@\" ", "$@", and "$(echo $@)" when used as arguments [duplicate]

I would like to pass multiple arguments to the Tor browser (firefox) programatically through a function arbitrarily entitled tor. This is so as to command tor search terms and voila! My search terms. ...
user avatar
1 vote
2 answers
186 views

@ and * in bash loop [duplicate]

I found the following two loops yield the same output. Can you help me to understand what the differences are between the @ and * in this particular case? #!/bin/bash ips=(8.8.8.8 8.8.4.4) for ip ...
Qian Chen's user avatar
  • 819
12 votes
0 answers
545 views

Should I use $* or $@? [duplicate]

Which one of $* or $@ is better to use (in array syntax,command line parameters, etc.) to avoid any bugs/problems in code? Or it does not make any difference?
munish's user avatar
  • 8,057
0 votes
3 answers
107 views

`$@` vs. `$*` behavior [duplicate]

The bash manual says: Regarding: $* When the expansion occurs within double quotes, it expands to a single word with the value of each parameter separated by the first character of the IFS special ...
De Novo's user avatar
  • 115
2 votes
0 answers
85 views

Bash: Special variables $@ vs. $* in For Loop [duplicate]

Using $@ instead of $* would preserve quoting. Consider the following script: #!/bin/bash # Test.sh for arg in $@ do echo "I found the argument $arg" done ./Test.sh "One Two Three" I reach the ...
sci9's user avatar
  • 527
0 votes
0 answers
59 views

Why isn't passed quoted $@ a single argument? [duplicate]

Why isn't passed quoted $@ a single argument? f2() { echo "f2: $1" } f1() { local x=("$@") f2 "${x[@]}" } f1 x y Invocation: $ bash t537.sh f2: ...
pmor's user avatar
  • 619
2 votes
0 answers
41 views

When would you use $* instead of $@ in Bourne shells? [duplicate]

In Bourne shell and its offshoots like Bash, I believe the only difference between $* and $@ is that $@ expands in double quotes so that each argument ends up as a single word even if it contained ...
user129758's user avatar

15 30 50 per page