i cannot give array declaration in shell script

Dear all,
i m unable to give array decalartion in solaris Operating system shell script

and script was so.sh

declare -a bull[90]

for i in 1 2 3 4 5 6 7 8 9
do

bull[$i]=$i
echo "${bull[$i]}"

done

it is throwing an error called

so.sh: declare: not found
so.sh: bull[1]=1: not found
so.sh: bad substitution

Sir if u cud help ragrding this issue

For starters, "declare" means nothing to the shell.
If you are going to be using arrays, I'd suggest you switch to the korn shell, which I find more efficient in handling arrays than any other shell. In korn shell, you set an array with:

# set -A bull 1 2 3 4 5 6 7 8 9

This sets array "bull" with numbers 1 through 9 in spots 0 through 8, respectively.

Actually "declare -a" is supported in the bash shell.

If the bash shell is available on your system, then the following should work (you may need to change "/usr/local/bin/bash" to point to wherever bash is installed on your system)

#!/usr/local/bin/bash

declare -a bull

for i in 1 2 3 4 5 6 7 8 9
do
    bull[$i]=$i
    echo "${bull[$i]}"
done

You can also perform the loop as follows

for  (( i=1; i < 10; i++ ))
do
    bull[$i]=$i
    echo "${bull[$i]}"
done

Sir i m unable to do .. above mentioned in a script ..

It shooting same old error.

ara.sh: declare: not found
ara.sh: syntax error at line 3: `(' unexpected

ara.sh is

declare -a bull[10]

for (( i=1; i < 10; i++ ))
do
bull[$i]=$i
echo "${bull[$i]}"
done

What shell are you using?

Sir i m using BASH shell in solaris..

Sir i m using Bash Shell in which i m unable to work out this code..

What is the output of the following?

bash --version
whence bash

when i execute

$bash --version

GNU bash, version 3.00.16(1)-release (sparc-sun-solaris2.10)
Copyright (C) 2004 Free Software Foundation, Inc.

Are you executing this command from the command line or inside your script (which you should) ?

I m unable to execute it. It is shooting same error.

Add the "ptree $$" command in your script before the "declare" command and post its whole output.

Sir after adding ptree $$ in program...

this is Output:

356 /usr/lib/ssh/sshd
19148 /usr/lib/ssh/sshd
19151 /usr/lib/ssh/sshd
19153 -bash
19175 sh ara.sh
19176 ptree 19175
ara.sh: declare: not found
ara.sh: syntax error at line 4: `(' unexpected

You are launching your script the wrong way.
Instead of running "sh ara.sh", change the script to be executable:

chmod +x ara.sh

Then, you'll be able to run it like a regular program

./ara.sh

You should also probably rename it to ara.bash as it is a bash script.

Alternatively, you can just launch the proper interpreter:

bash ara.sh

Sir, Now i can execute the script ..Thanks a lot for u tip it really worked.

of changing mode to executable ...and Sir i have not renamed the script even though it executed.

Sir, Now i can execute the script ..Thanks a lot for u tip it really worked.

of changing mode to executable ...and Sir i have not renamed the script even though it executed.

But Sir i have doubt y u have asked ptree $$ (process tree) to put before declare command. Cud explain me about that also.

Sir, Now i can execute the script ..Thanks a lot for u tip it really worked.

of changing mode to executable ...and Sir i have not renamed the script even though it executed.

But Sir i have doubt y u have asked ptree $$ (process tree) to put before declare command. Cud you explain me about that also.

That was intended to help understanding why your script wasn't executed by the expected shell. I.e. for debugging purpose. Now it works, you can remove that line from your script.

Sir please Elucidate the use of ptree $$ .. in other purposes also.

i have tired this command

find /data -type f -mmin 5 -print

but it is not working