tags:

views:

104

answers:

2
in localpath i have files with names 
myfile1_20090821.dat
myfile2_20090831.dat
myfile3_20090811.dat
myfile4_20090822.dat
myfile5_20090825.dat
type="OP"
module="abc"
if [ $type == 'OP' ]; then
case $module in
abc) x=1
     while [ $x -le 5 ]
     do
     INPUT_FILE[$x]=`ls localpath/myfile$x*.dat`
     x=$(( $x + 1 ))
     done;;
*) echo "not.......";;
esac
fi

its giving error :ls localpath/myfile$1*.dat not found

plz help me

A: 

My version of your program:

#!/usr/bin/bash

type="OP"
module="abc"
if [ $type == 'OP' ]; then
case $module in
abc) x=1
     while [ $x -le 5 ]
     do
     INPUT_FILE[$x]=`ls localpath/myfile$x*.dat`
     x=$(( $x + 1 ))
     done;;
*) echo "not.......";;
esac
fi

Gives no error messages. Do you have a shebang line in your version?

Actually, mine works without the shebang also. I'm using Cygwin.

pavium
+1  A: 

Basic script looks valid, but, will only work if you run it from the parent directory of " localpath"

i.e. if you do an 'ls' from the directory where you are running the script you should see the localpath directory listed.

Try fully qualifiying the directory.

James Anderson