Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
错误:";主页/文件“;Bash/ksh程序中的意外事件_Bash_Shell_Unix_Scripting_Ksh - Fatal编程技术网

错误:";主页/文件“;Bash/ksh程序中的意外事件

错误:";主页/文件“;Bash/ksh程序中的意外事件,bash,shell,unix,scripting,ksh,Bash,Shell,Unix,Scripting,Ksh,在if子句中获取错误,该子句表示: /home/files unexpected. 我不知道怎么了,这是KornShell(ksh)的脚本 #/bin/ksh selectPart=“选择。” filePart=“\u文件” 而read-r索引文件;做 读取-r cobol文件时;做 query=$selectPart“${indxFile}”$filePart if[[find/home/files-name“${cobolFile}”| xargs grep$query]];然后 同时读

if
子句中获取错误,该子句表示:

/home/files unexpected. 
我不知道怎么了,这是KornShell(ksh)的脚本

#/bin/ksh
selectPart=“选择。”
filePart=“\u文件”
而read-r索引文件;做
读取-r cobol文件时;做
query=$selectPart“${indxFile}”$filePart
if[[find/home/files-name“${cobolFile}”| xargs grep$query]];然后
同时读取-r脚本文件;做
打印“${scriptFile}”
完成“${indxFile}”.txt
fi
完成
如果出现以下情况,您只需在条件周围删除
[[]]

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
#/bin/ksh
selectPart=“选择。”
filePart=“\u文件”
而read-r索引文件;做
读取-r cobol文件时;做
query=$selectPart“${indxFile}”$filePart
findResult=find/home/files-name“${cobolFile}”| xargs grep$query
回显“findResult:${findResult}”
如果[${findResult}-eq 0]];然后
同时读取-r脚本文件;做
打印“${scriptFile}”
完成“${indxFile}”.txt
fi
完成
您可能需要
>“${indxFile}”.txt
,否则它将被每个内部while循环覆盖;结果取决于命令是否成功
[[
是一个特例。
[[
]
之间的内容是一个表达式,而不是一个命令。这是否意味着只有在名为
$cobolFile
的至少一个文件中的“${cobolFile}”中存在
$query
时,if子句才会计算为true,是吗
#!/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