ps -ef |grep -v 在shell sh 脚本中貌似无效?

原文链接: http://www.cnblogs.com/FlyAway2013/p/10858028.html

想通过ps -ef |grep erdp_ |awk '{print $2}' 获取 erdp_ 开头的进程id, 执行在终端环境下执行是ok的,但是在 sh 脚本里面竟然多出了 两个

root 11400 4280 0 17:08 pts/5 00:00:00 /bin/bash ./kill.sh erdp_system_app

root 11401 11400 0 17:08 pts/5 00:00:00 /bin/bash ./kill.sh erdp_system_app

root 11403 11401 0 17:08 pts/5 00:00:00 grep erdp_system_app

root 29942 1 3 12:22 pts/0 00:10:10 java -Xms512m -Xmx512m -Dfile.encoding=UTF-8 -DSERVER_PORT=8082 -jar erdp_system_app-2.0.0-SNAPSHOT.war linkServerPId

ps -ef |grep erdp_ |awk '{print $2}' | grep -v 可以过来 第三行, 但是 前面两行是怎么出现的呢?

不管怎么样, 通过下面的命令就好了:

ps -ef |grep erdp_  |  grep -v | grep -v 文件名

或者:

ps -ef |grep erdp_  | grep -vE '(grep|/bin/bash)'

posted on 2019-05-13 17:47 CanntBelieve 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/FlyAway2013/p/10858028.html

猜你喜欢

转载自blog.csdn.net/weixin_30338497/article/details/94954954