我有以下程序
query=$selectPart"${indxFile}"$filePart
if find /home/test -name "${cobolFile}"| xargs grep $query;then
print "${cobolFile}"
while read -r scriptFile;do
print " "
done < listScripts.txt
但是grep查询的输出正在打印到stdout。如何抑制此输出?
答案 0 :(得分:2)
以下内容应该有效
if find /home/test -name "${cobolFile}"| xargs grep $query | grep -v grep;then
答案 1 :(得分:0)
if find /home/test -name "${cobolFile}"| xargs grep -q $query;then
这个shd做的伎俩:D
答案 2 :(得分:0)
if [ "$(find /home/test -name "${cobolFile}" -exec grep $query {} + )" ]
then
print "${cobolFile}"
while read -r scriptFile
do
print " "
done < listScripts.txt
fi