Alexander Mills
Alexander Mills

Reputation: 100290

Using pkill, how can I find out how many processes matched

We may not know how many processes actually died as a result of a pkill command, but is there a way to echo how many processes matched?

pkill -f "bin/ql_node_server"

is there a switch to pkill that will echo how many processes matched?

on MacOS, if I use the -c option with pkill, I get:

pkill: illegal option -- c
usage: pkill [-signal] [-ILfilnovx] [-F pidfile] [-G gid]
             [-P ppid] [-U uid] [-g pgrp]
             [-t tty] [-u euid] pattern ...

Upvotes: 1

Views: 1211

Answers (1)

Vitaliy Andrianov
Vitaliy Andrianov

Reputation: 355

You can use -c flag.

From man pkill:

-c, --count Suppress normal output; instead print a count of matching processes. When count does not match anything, e.g. returns zero, the command will return non-zero value.

Upvotes: 3

Related Questions