A quick query

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.

command executed from command line and output is an array with values as desired

executing same from script

Excerpt of the script is something like this

I appreciate if the issue can be resolved as soon as possible.

Strange.. It works for me.

#! /bin/bash
x=(`ls test*`)
echo ${x[1]}
echo ${x[@]}
$ ./test.sh
test.pl
test.cgi test.pl test.sh

@balajesuri. Thank you for your reply. I believe removing round paranthesis doesn't make it an array. Please correct my understanding.

Secondly, /2702/ is just a directory with files.

Use bash iodata_extr or ./iodata_extr instead of sh iodata_extr

2 Likes

Bourne shell "sh" does not support this...

s=(`ls -lrth /2702/ | awk '{print $9;}' | sed s/iostat.// | cut -c5-6`) 

use bash...

1 Like

it worked with bash...Thank you all for valuable time and support.

HI EMBEDUX

IM WORKING IN DATA WAREHOUSING PROJECTS
PRESENT WHICH TECHNOLOGY BETTER FOR UNIX...

AND PLEASE TELL ME WHICH UNIX BOOK SUITABLE FOR UNIX ADMINISTRATION

THANKS!

Make your own thread, explain your question a lot better, and stop shouting in allcaps please.