Killing all python scripts except grep process and a specific python script

How can I run command in bash to kill all python scripts except script called test.py and the grep's pid itself, in case we are using something like ps -ef |grep

I think I can use something like pgrep python to ignore the grep process, but how do I also exclude the test.py script? I know there is an option to do grep -v, is there option to do pgrep -v

Clarification: except grep process- means when we do for example ps -ef |grep test1.pywe get also the grep pid that used to bring this result.
I don't want to kill it as this process is no longer exist in the stage that results are shown.

添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论