`How to get PID from ps command in linux?
A
A
Alexander Myasnikov2014-12-27 18:10:46
linux
Alexander Myasnikov, 2014-12-27 18:10:46

How to get PID from ps command in linux?

Command `ps -e | grep ghc produces:

21965 ?        00:00:00 runghc
21966 ?        00:00:12 ghc

How to change the command to get not strings but only PID values?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey Lerg, 2014-12-27
@amyasnikov

ps -e | grep ghc | awk '{print $1}'

P
protven, 2014-12-27
@protven

I upvoted the previous authors, of course, but awk is not needed here at all.
ps -A -o pid is sufficient.

H
HB, 2014-12-27
@heavybit

ps -e | awk '/ghc/ {print $1}'

V
Vlad Zhivotnev, 2014-12-27
@inkvizitor68sl

pgrep ghc

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question