Question

I need this done ASAP. Please write a bash shell script that does the following: Prints...

I need this done ASAP. Please write a bash shell script that does the following:

  • Prints out how many users are logged on.

    1. This can be accomplished using who and wc.

  • Prints out a list of currently logged on users.

    1. This can be accomplished using who, grep, regular expressions, and echo.

  • Prints out how many processes you have running from past days, and a list of those jobs.

    1. Use `whoami` to get your username.

    2. Run ps -ef and see how the jobs running from the past can be identified.

    3. Then use ps, grep, cut, wc to get the count, and again to get the list.

  • Output should be formatted as follows:

    1. There are currently <#> users logged on.

    2. Users logged on: <username>.

    3. You have <#> processes still running from the past.

      1. <username> <PID> <date> <time> <process>

Please also write another script that determines the existence and readability of all the filenames given as command line arguments:

  • Output should be in three sections. Example:

    • files: file1 file2 file3 file4 file5

    • The following does not exist:

      • file1

    • The following exists but you cannot read them:

      • file2 file5

    • The following exist and you can read them:

      • file3 file4

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a=`w | wc -l`
echo "There are currently $a users logged on"
echo


echo "Users logged on: `whoami`"
echo

n=`ps -efu | wc -l`
echo "You have $n processes still running from the past"
echo

ps -efu

FILES="$@"
for i in $FILES
do
   if [ ! -f $i ]
   then
       echo "The following does not exist: $i"  
   elif [ -w $i ]
   then
       echo "The following exists but you cannot read them: $i"
   else [ -r $i ]
       echo "The following exist and you can read them: $i"
   fi
done

if you have any doubt then please ask me without any hesitation in the comment section below , if you like my answer then please thumbs up for the answer , before giving thumbs down please discuss the question it may possible that we may understand the question different way and we can edit and change the answers if you argue, thanks :)

Add a comment
Know the answer?
Add Answer to:
I need this done ASAP. Please write a bash shell script that does the following: Prints...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a bash shell script to carry out each of the following tasks: What to Do:...

    Write a bash shell script to carry out each of the following tasks: What to Do: a. Safe Delete: When you use the “rm” command in Linux, it will delete the specified files, with no chance for recovering them back later. Write a script (called srm) that will safely delete the files passed to it as command-line arguments. For example, typing the command: “srm file1 file2 file3”, the script shall not actually delete these files, but instead it shall move...

  • In UNIX Write a script that checks each minute and reports on who logs in and...

    In UNIX Write a script that checks each minute and reports on who logs in and who logs out. You can follow the steps below (not the only way): Using the commands who and cut, extract the list of usernames currently logged in the system To check after a minute, the sleep command can be used: sleep 60 Get the new list of users logged in after a minute For each user in the list; check if he is in...

  • You will create a shell script that prints out the following information about the system it is run on: • The system’s n...

    You will create a shell script that prints out the following information about the system it is run on: • The system’s name and IP address • How much memory the system is currently using, and how much total memory it has • The number of CPUs of the machine • The number of unique users on the system at that moment When your script is run, each of these values should be clearly labeled in the output, such as...

  • Question I This question carries 20% of the marks for this assignment. You are asked to...

    Question I This question carries 20% of the marks for this assignment. You are asked to develop a set of bash shell script: Write a script that asks for the user's salary per month. If it is less or equals to 800, print a message saying that you need to get another job to increase your income, what you earn is the Minim living cost. If the user's salary is higher than 800 and below 2000, print a message telling...

  • computer networks help please !!! could someone help with the following tasks! ANY HELP WILL BE...

    computer networks help please !!! could someone help with the following tasks! ANY HELP WILL BE IMMENSELY APPRECIATED! THANKS. Task 1 In the following scenario, we would like to find out more information about a host that is on out network. Given an IP address we would like to search for additional information, we can start with obtaining the IP address off the default route. When running on a Linux VM, this like most likely to be the internal IP...

  • LINUX QUESTIONS (dont have to display output, I will be running these commands myself to check...

    LINUX QUESTIONS (dont have to display output, I will be running these commands myself to check the output) Display the command(s) used to do the following: create an empty file called history by using just a redirection operator. Verify and show. Show/verify all results (i.e., all commands and their corresponding outputs). Wait 1 minute or more and then display the command(s) used to do the following: change the timestamp on the history file you just created. Verify/display the change. Show/verify...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT