FreeBSD 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64

grep (GNU grep) 2.5.1-FreeBSD

Hi. I want to check availability of Asterisk process, so I use this command:

ps aux | grep /usr/local/sbin/asterisk

But the output is not relevant bacause it contains two strings (the first is for Asterisk process and the second is for grep process):

asterisk 44044   9.8  2.1  866912 133628  -  Is   14:35     121:27.41 /usr/local/sbin/asterisk -n -F -U asterisk
root     44242   0.0  0.0   14796   2484  4  S+   09:50       0:00.27 grep /usr/local/sbin/asterisk

So I want to exclude "grep" string. In Linux I can use flag -v, but what should I do in FreeBSD?


Quick answer: Change the pattern so it doesn't show up in ps, but still matches, for example use square brackets to search for


Maybe better answer: Use a program like pgrep to "look up or signal processes based on name and other attributes"

  • Thank you, the "-f" flag of pgrep is solution. – rGA145 Nov 7 '18 at 7:15
  • 1
    So the command will be: pgrep -lf /usr/local/sbin/asterisk – rGA145 Nov 7 '18 at 7:16
  • Welcome:) I usually use the -f flag on linux, and the bsd -l flag looks equivalent to linux's -a flag (list full command line & pid) – Xen2050 Nov 7 '18 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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