2

I'm curious if these are just synonyms or if there is any difference among these two notations used to iterate through an array in bash:

${array[@]}

${array[*]}

I use both in the same way and they don't seem to yield different results:

array=(one two three four)
for stuff in ${array[@]} ; do echo $stuff ; done
one 
two
three
four

returns the same as:

array=(one two three four)
for stuff in ${array[*]} ; do echo $stuff ; done
one 
two
three
four

Is there any difference or should I consider both identical?

runlevel0
  • 2,715
  • 2
  • 24
  • 31

0 Answers0