Home > Back-end >  Linux Terminal : Process that ends with a specific name
Linux Terminal : Process that ends with a specific name

Time:11-21

My question is : How do I find all the running processes that end with "sh". I know that "ps aux" lists all the processes that are running and also "grep" prints a specific named process which is written inside " ". I know I have to combine the command "ps aux" and also "grep" with a wildcard.

My solution is ps aux | grep "*sh" but it does not run properly. How could it be solved?

CodePudding user response:

Try: ps aux | grep "sh$"

The "$" sign is regular expression that is used for pattern match at the end of the line. In this case, the pattern is "sh" so we used "sh$"

CodePudding user response:

Suggesting to use pgrep command. See here.

pgrep -f "sh$"

Will return list of pids

pgrep -af "sh$"

Will return list of pids and commands

  • Related