Thanks a lot for the reply. It kinda feels special when the moderator replies
I tried the following script (Sorry, should've tried this before starting this thread) :
Code:
#!/bin/sh
planets[9]=Pluto
printf ${planets[*]}
exit 0
and the output was same: Pluto
So, this is what I understand:
The line planets[9]=Pluto declares/defines an array that can store 9 members and it's ninth member is Pluto. Then the statement printf ${planets[*]} Prints the contents of the array as a string. Also since the other members of the array planets are not defined the shell substitues "" whenever they are requested.
Is my interpretation correct?
I also want to ask that what does the following statement do:
Code:
set -a planets mecury venus
I looked up the man page of the set command, but could not find any refernece to the -a flag. What I know about the set command is that a simple set command like:
Code:
set planets mecury venus
would set $1 to planets, $2 to mercury, $3 to venus etc. There were also other uses of set like storing a random number in a variable, but I could not find what the -a flag did.
Thanks for all the help.