Hello All,
i am facing an issue and could not understand the possible reason...
When the following command is executed from command line (from # prompt) the output is as desired but executing the same from a shell script, the result is an error. It is important for the command to execute in the script as there are other calculations dependent on this variable.
Quote:
s=(`ls -lrth /2702/ | awk '{print $9;}' | sed s/iostat.// | cut -c5-6`)
command executed from command line and output is an array with values as desired
Quote:
bash-3.00# echo ${#s[@]}
144 ---> total no. of vaules from above command
bash-3.00# echo ${s[141]}
01 ----> one of the array values
bash-3.00#
executing same from script
Quote:
bash-3.00# sh iodata_extr
iodata_extr: syntax error at line 6: `s=' unexpected
Excerpt of the script is something like this
Quote:
#!/bin/bash
cd /
j=3;
k=p;
a=1;
s=(`ls -lrth /2702/ | awk '{print $9;}' | sed s/iostat.// | cut -c5-6`)
I appreciate if the issue can be resolved as soon as possible.