Linked Questions
44 questions linked to/from What is the difference between $* and $@?
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 ...
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
...
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 ...
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?
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 ...
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 $@ ...
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&...
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?
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. ...
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 ...
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?
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 ...
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 ...
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: ...
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 ...