Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to get a list of all the processes whose parent is $pid. This is the simplest way I've come up with:

pstree -p $pid | tr "\n" " " |sed "s/[^0-9]/ /g" |sed "s/\s\s*/ /g"

Is there any command, or any simpler way to get the list of children processes?


share|improve this question
up vote 9 down vote accepted

Yes, using the -P option of pgrep,

i.e pgrep -P 1234 will get you a list of child process ids.

share|improve this answer
I'm afraid your answer is correct, but my question was incorrect. Therefore I accept your answer (which I didn't know, btw) and I opened another thread with the question I really meant to ask: unix.stackexchange.com/questions/67668/… – STenyaK Mar 12 '13 at 13:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.