简体   繁体   中英

How can i output the children of a process as a number in Bash

I want to output to a text.log the count of the childrens of a process searching them by name not with PID. For example i want to count the processes of firefox by name and output them in the text file as a number "6" .

By PID using the ps command:

ps --ppid PID_OF_PROC | wc -l

If you need it recursively, meaning childs of childs included then use:

ps x --ppid PID_OF_PROC | wc -l

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM