LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   using bash to find the pid of a process called "name" (https://www.linuxquestions.org/questions/linux-newbie-8/using-bash-to-find-the-pid-of-a-process-called-name-247214/)

poiuytrewq 10-25-2004 04:34 PM

using bash to find the pid of a process called "name"
 
how would one use a bash script to get the pid of a process by using its name?

i need to use the number in a script, so using ps -A|grep thename wont do

any help?

Tinkster 10-25-2004 04:37 PM

ps -A | grep <name> | awk '{print $1}'

for example ...


Cheers,
Tink

mjrich 10-25-2004 08:45 PM

Or even simpler... pidof <name> ...

Tinkster 10-25-2004 09:01 PM

See, I learn something new every day :)

Thanks for that one!


Cheers,
Tink


All times are GMT -5. The time now is 05:10 PM.