See my comment in your post on using "urgent" in the topic, thanks.
Your first script uses ksh syntax to declare an array with set -A . In your second script you use a shebang to call bash, which has a different syntax to declare an array like:
$ declare -a myarray=(eins zwei drei)
$ echo ${myarray[1]}
zwei
#or
$ myarray=(eins zwei drei)
$ echo ${myarray[2]}
drei
Thanks again, I am just curious that I includedksh library in the starting of script by writing below code -
#!/bin/bash
#!/bin/ksh
#!/bin/sh
#!/bin/csh
Then why it picked up only bash syntax
The #! in exactly the first two character positions of a script tell the command interpreter which program to run to read and execute the script. All the other lines are pure comments and thus ignored. Nothing to do with libraries.
At the very beginning of your script then it should run fine, provided that you make the script executable ( chmod +x ) and run it like /path/to/script , or like script if the path leading to the script is in your search path.
If you start the script like
bash script
then that will not work, since the first line is simply a comment and ksh will not be used.
You can also make sure ksh is used by calling it like:
ksh script
--
Actually it is the first two bytes and they inform the OS' program loader that the file is a script and that the remainder of the line specifies which command interpreter to run, with the script name as argument. This command interpreter is subsequently started and it then reads the script and typically interprets this first line - that starts with #! (the "shebang") - as comment, because it starts with # .