Hi all,
I am working in ubuntu for past few weeks .Since I was working in debian I had no problem with arrays.I followed the same method in ubuntu,but is is not working as I expected.
Name[1]="apple"
Name[2]="orange"
print ${Name[1]}
Expected result is apple.But I got a error as "Bad substitution" .what is the reason.
Thanks in advance .
I know that echo will print the output.After using echo also I get the same result.
This is what I'm getting ,
filt.sh: 4: Name[1]=apple: not found
filt.sh: 5: Name[2]=orange: not found
filt.sh: 6: Bad substitution
Scott
June 7, 2010, 2:20am
4
Are you using CSH? Or what shell are you using (your original code works fine for me (in ksh)) If it's SH, then there are no arrays. Use BASH or KSH?
In Ubuntu, sh points to dash (not bash). Therefore: be explicit and either prepend your code with #!/bin/bash or call the script with bash ...
Thanks for your replies,
But still now the problem is there .I tried with sha-bang "#!/bin/bash".Also I'm using BASH only.
How do you exactly call your script? Try ./script or only script
What's the output of ls -l `which bash`
What's the output of echo $0
I executing like
./script.sh
output of ls -l `which bash`
-rwxr-xr-x 1 root root 729040 2009-03-02 19:52 /bin/bash
The result of echo $0 is the ./script.sh.
Problem solved by run the script using /bin/sh.distrib.So the /bin/sh should have a link with /bin/sh.distrib .