0

This question already has an answer here:

I am trying to list all the ffmpeg processes that are currently running on Debian machine (Ubuntu 15).

I use the following command:

ps aux | grep 'ffmpeg'

If only one ffmpeg process is running, I still get two results. One for the actual process, and one for grep that is looking for ffmpeg in the process list.

max      21599 13.2  3.0 503848 92288 ?        Rl   01:39   1:18 ffmpeg -f video4linux2 -i /dev/video0 -f mpeg1video -b:v 800k -r 30 http://127.0.0.1:8082/oops/1024/640/ -nostdin -nostats -loglevel fatal
max      23789  0.0  0.0  13688  2172 pts/3    S+   01:49   0:00 grep --color=auto ffmpeg

How can I modify my request so that the grep result which is actually my request is omitted from the output?

marked as duplicate by Gilles linux Sep 6 '15 at 22:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

You can use a trick :

ps aux | grep '[f]fmpeg'

Here [] is a format used for indicating range of characters to match using grep, we are using [f] to match only f. As the [f] is converted into f already, the literal ps aux | grep 'ffmpeg' won't show up in ps output.

Also note that appearance of ps aux | grep 'ffmpeg' on the output of ps aux | grep 'ffmpeg' mainly depends on the time it takes for the process table to be shown.

Note that there is a program named pgrep to search for processes, you can us that if ps aux is not absolutely needed.

Not the answer you're looking for? Browse other questions tagged or ask your own question.