How can I search case insensitive in pgrep?
[BSD only]
[FreeBSD pgrep man page]
From the man page of pgrep: man pgrep
under option i
-i Ignore case distinctions in both the process table and the
supplied pattern.
So, we can just use the option i
like following:
pgrep -fi 'PATTERN'
i.e.:
pgrep -f 'chrome'
echo $?
1
But including -fi
option works:
pgrep -fi 'ChRoMe'
Output:
> 872
910
41391
60087
60090
60092
If the string is not too long:
pkill -f '[Pp][Aa][Tt][Ee][Rr][Nn]'
kill `ps ax | grep -i PATTERN | awk '{ print $1 }'`
Will kill all of your process matching case insensitive process using the magical `