Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 236

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

missing components for Project Launch

Answered: 1 week ago

Question

Explain the issues of safety unique to small businesses.

Answered: 1 week ago

Question

How are members held accountable for serving in the assigned roles?

Answered: 1 week ago