grep "str" file > /dev/null
if [ $? -eq 1]; then
echo "no str"
else
echo "find str"
fi
输出到/dev/null中为了不打印输出
grep "str" file > /dev/null
if [ $? -eq 1]; then
echo "no str"
else
echo "find str"
fi
输出到/dev/null中为了不打印输出
转载于:https://www.cnblogs.com/chencesc/p/6291856.html