1

I want to have an alias to do something like pkill -f PATTERN but ignoring the case of the pattern. This is what I have after looking around but it's not working

alias pkf="kill `ps ax | grep -i $1 | awk '{ print $2 }'`"
alias pkf9="kill -9 `ps ax | grep -i $1 | awk '{ print $2 }'`"

2 Answers 2

1

man pkill :

       -i, --ignore-case
          Match processes case-insensitively

So :

pkill -fi PATTERN
1
  • This is available since procps-ng 3.3.11 on Linux (2015), and earlier still on FreeBSD. Commented Oct 17, 2022 at 8:14
0

You can use also killall. The command to ignore case will be:

killall -I process_name

WARNING: this command will work on this way only in Linux. Do not use it in AIX, Solaris, HP-UX!

According to the commit in GitHub killall is 21 years old.

You must log in to answer this question.