echo "All Index: ${NAME[*]}"equals toecho "All Index: ${NAME[0]} ${NAME[1]} ${NAME[2]} ${NAME[3]} ${NAME[4]}"echo "All Index: ${NAME[@]}"equals toecho "All Index: ${NAME[0]}" "${NAME[1]}" "${NAME[2]}" "${NAME[3]}" "${NAME[4]}"if the first character ofIFSvariable is a space (default)
You can see the execution result in copy.sh.
The default value of IFS variable is $' \t\n'. ${array[*]} and $* outputsoutput strings that split the arraysplited by the first character of IFS variable. It is also possible to change itthe character to split.
NAME[0]=Deepak NAME[1]=Renuka NAME[2]=Joe NAME[3]=Alex NAME[4]=Amir IFS=: echo "All Index: ${NAME[*]}" # Output: `All Index: Deepak:Renuka:Joe:Alex:Amir` IFS= echo "All Index: ${NAME[*]}" # Output: `All Index: DeepakRenukaJoeAlexAmir` IFS=$', \t\n' echo "All Index: ${NAME[*]}" # Output: `All Index: Deepak,Renuka,Joe,Alex,Amir`