问题描述
当我检查进程列表并grep出那些对我有意思的内容时,结果中也包含 grep
本身。例如,要列出终端:
$ ps aux | grep终端
用户2064 0.0 0.6 181452 26460? Sl Feb13 5:41 gnome-terminal --working-directory = ..
user 2979 0.0 0.0 4192 796 pts / 3 S + 11:07 0:00 grep --color = auto terminal
通常我使用 ps aux | grep something | grep -v grep
来摆脱最后一项...但它不是优雅的:)
你是否有更优雅的黑客来解决这个问题(除了把所有的命令包装到一个单独的脚本中,这也是一件坏事)
解决方案