shell脚本grep -q用于if条件判断
作者:互联网
grep -q用于if逻辑判断
-q 参数,本意是 Quiet; do not write anything to standard output. Exit immediately with zero status if any match is found, even if an error was detected. 中文意思为,安静模式,不打印任何标准输出。如果有匹配的内容则立即返回状态值0。
例如:
if grep -q “username” home.txt
then
对username进行处理
else
处理
fi
参考博文:https://blog.csdn.net/sukhoi27smk/article/details/43372979
标签:脚本,username,shell,grep,zero,Exit,状态值,fi 来源: https://blog.csdn.net/rita0417/article/details/113659708