nginx -v或python -V等命令结果无法过滤处理

shell中某些命令输出不能直接写入管道进行处理,例如nginx -vpython -V,需要重定向输出之后才能进行处理。

范例1:

#获取nginx版本
[root@proxy opt]# nginx -v 2>&1 |cut -d' ' -f3
nginx/1.20.1

范例2:

#获取python版本
[root@proxy opt]# python -V 2>&1|awk '{print $2}'
2.7.5
posted @ 2022-07-07 17:55  areke  阅读(166)  评论(0)    收藏  举报