Home > front end >  Find all running processes with a certain name linux
Find all running processes with a certain name linux

Time:03-09

I am new to linux, and I want to write to a .txt file all of the running processes on my PC that has the word "con" in them.

The script I wrote:

#!/bin/bash
ps -A | grep "con" > con_proc.txt

Why is this not working?

CodePudding user response:

#!/bin/bash
ps -eaf | grep -i "con" > con_proc.txt

If you want to place inside of a script the contents of the script would be the above contents, for example script.sh.

To invoke the script you will need to do the following:

chmod  x script.sh
./script.sh

The first command gives the script execute permissions and the second command invokes the script.

CodePudding user response:

Linux has pgrep to do this.

$ pgrep -a con
...
  • Related