Skip to main content
improved content
Source Link
sakkke
  • 303
  • 1
  • 6
  • echo "All Index: ${NAME[*]}" equals to echo "All Index: ${NAME[0]} ${NAME[1]} ${NAME[2]} ${NAME[3]} ${NAME[4]}"
  • echo "All Index: ${NAME[@]}" equals to echo "All Index: ${NAME[0]}" "${NAME[1]}" "${NAME[2]}" "${NAME[3]}" "${NAME[4]}" if the first character of IFS variable 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` 
  • echo "All Index: ${NAME[*]}" equals to echo "All Index: ${NAME[0]} ${NAME[1]} ${NAME[2]} ${NAME[3]} ${NAME[4]}"
  • echo "All Index: ${NAME[@]}" equals to echo "All Index: ${NAME[0]}" "${NAME[1]}" "${NAME[2]}" "${NAME[3]}" "${NAME[4]}" if the first character of IFS variable is a space (default)

You can see the execution result in copy.sh.


The default value of IFS variable is $' \t\n'. $* outputs strings that split the array by the first character of IFS variable. It is also possible to change it.

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` 
  • echo "All Index: ${NAME[*]}" equals to echo "All Index: ${NAME[0]} ${NAME[1]} ${NAME[2]} ${NAME[3]} ${NAME[4]}"
  • echo "All Index: ${NAME[@]}" equals to echo "All Index: ${NAME[0]}" "${NAME[1]}" "${NAME[2]}" "${NAME[3]}" "${NAME[4]}" if the first character of IFS variable is a space (default)

You can see the execution result in copy.sh.


The default value of IFS variable is $' \t\n'. ${array[*]} and $* output strings splited by the first character of IFS variable. It is also possible to change the 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` 
fixed typo
Source Link
sakkke
  • 303
  • 1
  • 6
  • echo "All Index: ${NAME[*]}" equals to echo "All Index: ${NAME[0]} ${NAME[1]} ${NAME[2]} ${NAME[3]} ${NAME[4]}"
  • echo "All Index: ${NAME[@]}" equals to echo "All Index: ${NAME[0]}" "${NAME[1]}" "${NAME[2]}" "${NAME[3]}" "${NAME[4]}" if the first charactorcharacter of IFS variable is a space (default)

You can see the execution result in copy.sh.


The default value of IFS variable is $' \t\n'. $* outputs strings that split the array by the first character of IFS variable. It is also possible to change it.

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` 
  • echo "All Index: ${NAME[*]}" equals to echo "All Index: ${NAME[0]} ${NAME[1]} ${NAME[2]} ${NAME[3]} ${NAME[4]}"
  • echo "All Index: ${NAME[@]}" equals to echo "All Index: ${NAME[0]}" "${NAME[1]}" "${NAME[2]}" "${NAME[3]}" "${NAME[4]}" if the first charactor of IFS variable is a space (default)

You can see the execution result in copy.sh.


The default value of IFS variable is $' \t\n'. It is also possible to change it.

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` 
  • echo "All Index: ${NAME[*]}" equals to echo "All Index: ${NAME[0]} ${NAME[1]} ${NAME[2]} ${NAME[3]} ${NAME[4]}"
  • echo "All Index: ${NAME[@]}" equals to echo "All Index: ${NAME[0]}" "${NAME[1]}" "${NAME[2]}" "${NAME[3]}" "${NAME[4]}" if the first character of IFS variable is a space (default)

You can see the execution result in copy.sh.


The default value of IFS variable is $' \t\n'. $* outputs strings that split the array by the first character of IFS variable. It is also possible to change it.

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` 
update content
Source Link
sakkke
  • 303
  • 1
  • 6
  • echo "All Index: ${NAME[*]}" equals to echo "All Index: ${NAME[0]} ${NAME[1]} ${NAME[2]} ${NAME[3]} ${NAME[4]}"
  • echo "All Index: ${NAME[@]}" equals to echo "All Index: ${NAME[0]}" "${NAME[1]}" "${NAME[2]}" "${NAME[3]}" "${NAME[4]}" if the first charactor of IFS variable is a space (default)

You can see the execution result in copy.sh.


The default value of IFS variable is $' \t\n'. It is also possible to change it.

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` 
  • echo "All Index: ${NAME[*]}" equals to echo "All Index: ${NAME[0]} ${NAME[1]} ${NAME[2]} ${NAME[3]} ${NAME[4]}"
  • echo "All Index: ${NAME[@]}" equals to echo "All Index: ${NAME[0]}" "${NAME[1]}" "${NAME[2]}" "${NAME[3]}" "${NAME[4]}"

You can see the execution result in copy.sh.

  • echo "All Index: ${NAME[*]}" equals to echo "All Index: ${NAME[0]} ${NAME[1]} ${NAME[2]} ${NAME[3]} ${NAME[4]}"
  • echo "All Index: ${NAME[@]}" equals to echo "All Index: ${NAME[0]}" "${NAME[1]}" "${NAME[2]}" "${NAME[3]}" "${NAME[4]}" if the first charactor of IFS variable is a space (default)

You can see the execution result in copy.sh.


The default value of IFS variable is $' \t\n'. It is also possible to change it.

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` 
fixed answer
Source Link
sakkke
  • 303
  • 1
  • 6
Loading
improved content
Source Link
sakkke
  • 303
  • 1
  • 6
Loading
Source Link
sakkke
  • 303
  • 1
  • 6
Loading