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”
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”
本文讨论问题的代码,位于 Github:https://github.com/wangzixi-diablo/ngDynamic
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M