1
我已經在Linux中使用下面這個簡單的ksh腳本意想不到的Linux運營商/操作數,而測試的文件
#!/bin/ksh
set -x
### Process list of *.dat files
if [ -f *.dat ]
then
print "about to process"
else
print "no file to process"
fi
我在我的當前目錄下面的* .dat文件:
S3ASBN.1708140015551.dat S3ASBN.1708140015552.dat S3ASBN.1708140015561.dat S3HDR.dat
運行文件命令顯示如下:
file *.dat
S3ASBN.1708140015551.dat: ASCII text
S3ASBN.1708140015552.dat: ASCII text
S3ASBN.1708140015561.dat: ASCII text
S3HDR.dat: ASCII text
但是,當我運行ksh腳本時,它顯示以下內容:
./test
+ [ -f S3ASBN.1708140015551.dat S3ASBN.1708140015552.dat S3ASBN.1708140015561.dat S3HDR.dat ]
./test[9]: [: S3ASBN.1708140015552.dat: unexpected operator/operand
+ print no file to process
no file to process
任何線索爲什麼我得到unexpected operator/operand
和什麼是補救措施?