shell grep

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