-1

I currently have something like this. I am attempting to find a process with a certain name

>:~# ps | grep avahi-daemon
12499 avahi     3048 S    avahi-daemon: running [BlahBlah.local]
12500 avahi     3048 S    avahi-daemon: chroot helper
12538 root      2672 S    grep avahi-daemon  <---What is this

What is the 3rd line ? Why does it say grep avahi-daemon

Rajeshwar
  • 299

2 Answers2

1

It is returned, because it matches your grep pattern.

Specifically, all three lines contain the word "avahi-daemon', and as you requested, grep has parsed the output of ps, and found that, in addition to the two processes which actually are named avhai-daemon, there is also a process running, grep avahi-daemon, which matches. If you really don't want it returned, you need to add a "not matching" clause to your grep, and tell it that you want it to search for lines that contain avahi-daemon, but do NOT contain grep.

Don Simon
  • 524
  • 3
  • 9
1

One way to exclude grep from ps output is to not run grep.

You can filter ps output using its -C switch rather than piping its output.

To list only avahi-daemon processes, you can run this command:

ps -C avahi-daemon