在
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
您可以在 if 中删除条件周围的[[ ]]
:
if find /home/files -name "${cobolFile}" | xargs grep $query ; then
请提供您的任务的更多详细信息。以下是对相关代码的更新。
#!/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