我怎样才能阻止 grep 返回自己

dev*_*ull 1 grep

# ps -ef | grep gre
root     15067 63614  0 11:03 pts/0    00:00:00 grep --color=auto gre
Run Code Online (Sandbox Code Playgroud)

另一个例子

# ps -ef | grep sshd
root      1186     1  0 Jul26 ?        00:00:00 /usr/sbin/sshd -D
root     15439 63614  0 11:05 pts/0    00:00:00 grep --color=auto sshd
Run Code Online (Sandbox Code Playgroud)

如何停止 grep 命令被自身找到而不作为字段返回?

Sat*_*ura 6

更好的方法是pgrep用于该任务。如今,它似乎在大多数系统上都可用。