在if
子句中出现错误,其中包含:
/home/files unexpected.
我不知道出了什么问题,这是KornShell(ksh)脚本。
#!/bin/ksh
selectPart="SELECT."
filePart="_FILE"
while read -r indxFile; do
while read -r cobolFile; do
query=$selectPart"${indxFile}"$filePart
if [[ find /home/files -name "${cobolFile}" | xargs grep $query ]];then
while read -r scriptFile;do
print "${scriptFile}"
done < listScripts.txt > "${indxFile}".txt
fi
done < cobolNames.txt
done < indexedFiles.txt
答案 0 :(得分:1)
您可以删除if:
中条件周围的[[ ]]
if find /home/files -name "${cobolFile}" | xargs grep $query ; then
答案 1 :(得分:0)
请提供您的任务的更多详细信息。以下是相关代码的更新。
#!/bin/ksh
selectPart="SELECT."
filePart="_FILE"
while read -r indxFile; do
while read -r cobolFile; do
query=$selectPart"${indxFile}"$filePart
findResult=find /home/files -name "${cobolFile}" | xargs grep $query
echo "findResult: ${findResult}"
if [[${findResult} -eq 0]]; then
while read -r scriptFile;do
print "${scriptFile}"
done < listScripts.txt >> "${indxFile}".txt
fi
done < cobolNames.txt
done < indexedFiles.txt