Question
Question: bash Here is my bash code in linux: #the program displays the list of usernames and processes for each user that are currently active
Question: bash
Here is my bash code in linux:
#the program displays the list of usernames and processes for each user that are currently active on a linux server, then counts all processes for each and totals the amount of users and total processes.
while [ "$1" == "" ] do echo `date` echo "USER COUNT COUNT"
ps -eo user=|sort|uniq -c|awk '{ print $2 " " $1 }'|column -t processes=`ps -eo user|awk '{print $1}' |sort|uniq -u|egrep ''|wc -l` #this is not displaying correct number users=`ps -eo user|awk '{print $1}' |sort|uniq -u|egrep ''|wc -l` #this is not displaying correct number echo "$users USERS,TOTAL PROCESSES $processes"
sleep 5 done
My code doesn't display the current amount of USERS, and my TOTAL PROCESSES are incorrect.
How do I fix that so it displays correctly?
$ ./test.sh Mon 3 May 2021 7:13:56 PM CST User ID Count Crt0345 14 cth0124 2 pcp0019 4 10 USERS, TOTAL PROCESSES 236 $ ./test.sh Mon 3 May 2021 7:13:56 PM CST User ID Count Crt0345 14 cth0124 2 pcp0019 4 10 USERS, TOTAL PROCESSES 236Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started