2009-08-31 18 views
0
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 

その与えるエラー:LS localPathに/ myfileを$ 1 *UNIXのcase文でワイルドカードを使用する際の問題?

を見つけていないの.dat plzはあなたのプログラムの

答えて

1

Basicスクリプトを使用すると、スクリプトを実行しているディレクトリから「LS」を行うかどうかを確認する必要があり、すなわち

を有効に見えますが、あなたは「localPathに」の親ディレクトリからそれを実行した場合のみ動作しますlocalpathディレクトリがリストされます。

ディレクトリの完全修飾を試してください。

0

マイバージョン私を助ける:

 
#!/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 

は、エラーメッセージを与えません。あなたのバージョンにシボンのラインがありますか?

実際、私はシバンなしでも動作します。私はCygwinを使用しています。

関連する問題