The differece between $@ and $*
Hello,everyone
I'm a linux newbie from Shanghai.There's a question regarding $@ and $* which has confused me for a long time.Actually I have read the bash manual and some bibliographies,I found that they just talk about these two positional parameters' difference when they're double quoted.So what if they're assigned to a variable? I've done some tests below. Code:
set -- "First Arg" "Second" "Third:Arg" "" "Fifth: :Arg" |
I'm a linux newbie from Shanghai.
Doesn't mean nothing, Im a noob from Hell when it comes to open heart surgery :-] AFAIK \* is the concatenation (whole string) while @ the IFS-sep'ped parts: ]$ tellMeIWannaKnow() { i=("$*"); echo ${#i[@]}; } ]$ tellMeIWannaKnow onetwothree four 1 ]$ tellMeIWannaKnow() { i=("$@"); echo ${#i[@]}; } ]$ tellMeIWannaKnow onetwothree four 2 |
Thank you,unSpawn!
I understand what you're talking about."$@" will seperate arguments with IFS.But there's one thing I am also a little fuzzy on it. Code:
var=$@ |
All times are GMT -5. The time now is 03:00 PM. |