shell执行时文件命名导致的错误

 1、脚本check_nginx.sh的内容如下:

1 #!/bin/bash
2 count=$(ps -ef | grep nginx | grep -v grep | wc -l)
3 sleep 10
4 echo $count

2、执行ps -ef | grep nginx | grep -v grep | wc -l,真实结果为2

3、但是执行sh -x check_nginx.sh结果却为4,原因是执行文件的名字包含了匹配的关键字段“nginx”

原文地址:https://www.cnblogs.com/shengulong/p/6737495.html