Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

Thanks!

share|improve this question
add comment

1 Answer

up vote 3 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
add comment

Your Answer

 
discard

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.