How can I extract only the PID of a process?

5

My idea is to create a simple script that can search the PID of a process and kill it for example.

This is what I have done so far but has the problem of running 'ps' will not extract the PID.

echo "nome do processo : "
read $matança
ps -ax | grep $matança
    
asked by anonymous 17.02.2017 / 00:02

1 answer

1

You can use pgrep , for your case it would look like this:

pgrep -f $matança

Source: link

    
17.02.2017 / 12:09