How can I count and display on the screen root's active processes? And 1 more question about find

时间:2019-01-09 22:26:15

标签: bash

1st: Just like in topic. How can I count and display on the screen root's active processes? 2nd: How can i find normal files, modified more than 1 week ago, with SGID bit set, executable for group and others and directories with sticky bit set. All found files' names should be displayed on the screen and then saved in file records? I tried like this but didn't work:

find . -type f -mtime +7 -perm 2011 -print | find . -type d -perm /1000 -print | tee records

There's nothing in my records file and nothing on my screen, did I do something wrong?

2 个答案:

答案 0 :(得分:1)

This does the 'display and count root's processes'

pgrep -U 0 -a | tee /dev/stderr | wc -l

You should open a separate question for part 2.

答案 1 :(得分:0)

您可以将ps命令与grepwc -l一起使用

$ ps aux | grep ^root | wc -l