Question

Subject: Shell Scripting Practice A File: practice-script-a Create File practice-script-a that: 1. Accepts any number of...


Subject: Shell Scripting Practice A
File: practice-script-a

Create File practice-script-a that:
1. Accepts any number of userids on the command line

2. For each userid, display the userid, PID, CPU time, and
current command for each process owned by that userid

Your output should look similar to this example:

practice-script-a doug.jones
User: doug.jones PID: 8748 TIME: 00:00:00 COMMAND: /usr/lib/systemd/systemd --user
User: doug.jones PID: 8749 TIME: 00:00:00 COMMAND: (sd-pam)   
User: doug.jones PID: 8750 TIME: 00:00:00 COMMAND: sshd: doug.jones@pts/5
User: doug.jones PID: 8751 TIME: 00:00:00 COMMAND: -bash
User: doug.jones PID: 10984 TIME: 00:00:00 COMMAND: vim practice8
User: doug.jones PID: 11217 TIME: 00:00:00 COMMAND: sshd: doug.jones@pts/29
User: doug.jones PID: 11218 TIME: 00:00:00 COMMAND: -bash
User: doug.jones PID: 12702 TIME: 00:00:00 COMMAND: sshd: doug.jones@pts/31
User: doug.jones PID: 12703 TIME: 00:00:00 COMMAND: -bash
User: doug.jones PID: 14136 TIME: 00:00:00 COMMAND: vim q5a

3. Your script should use the "echo" command for output, the "ps" command
to get the PID, TIME, and COMMAND information, and 'for' loops with
variables to couple the information. There is no need for awk, sed, vim,
or other utilities in this script, and you should avoid them.

Although the length of the script file is NOT a factor in your grade,
you should expect the script to be 10 to 15 lines, plus any additional
comments you add.

4. Your script should include a series of comments that fully
describes your script, including the purpose of each line. You
may use a separate comment block or include the comments on
each line of code.

Email 2
Subject: Shell Scripting Practice B
File: practice-script-b

Create File practice-script-b that:
1. Accepts a file name as the first argument

2. Accepts a list of directories (any number of directories)
as the remaining arguments

3. Searches each directory (NO subdirectories) for the specified file

4. Each time the target file is found in one of the specified directories:
(a) Display the full path name of the file
(b) Display the owner name of the file
(c) Display the permission of the file as an octal number

Example Command:
practice-script-b makefile . / /bin /home ~
  
Example Output:
makefile found in . (owner: glen.sasek, permission: 700)

5. Your script should use the 'find' command to view and print the
file information (i.e. -printf with %h, %u, %m codes), and you
should use a 'for' loop to control the 'find' command's search
through the target directories. Be sure to remember to use
the -maxdepth option to prevent searching sub-directories.

As before, there is no need for awk, vim, sed, or any other
utilities other utilities, and you should avoid them.

Although the length of the sript file is NOT a factor in your grade,
you should expect the script to be 8 to 10 lines, plus any additional
comments you add.

6. Your script should include a series of comments that fully
describes your script, including the purpose of each line. You
may use a separate comment block or include the comments on
each line of code.

Homework Answers

Answer #1

practice-script-a.sh
**********************

#!/bin/bash

echo "User: $1" ps -eo pid,user,args c

for var_name in $(seq 1 20); do
ps -eo pid,user,args c
done

We are allowed to do only 4 exercise out of any given.

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 :)

Know the answer?
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
Similar Questions
Create shell scripts, each in its own .sh file. Please include a shebang line at the...
Create shell scripts, each in its own .sh file. Please include a shebang line at the top of the script as well as appropriate comments through out. Write a script that uses sed to replace all instances of the name "Lizzy" with "Elizabeth" in a text file. Save the updated text in a new file named after the original text file with "-formal" appended before the file extension, e.g. old.txt -> old-formal.txt. Test this script on the data-shell/writing/data text files....
5. Write a bash command that will display the name of every file on the Linux...
5. Write a bash command that will display the name of every file on the Linux system whose file contaent contains the string "doug.jones". The command must run in the background, must redirect standard error to /dev/null, and must redirect standard output to ~/out. 6. Write a bash command that will kill all of the even-numbered processes associated with your userid, and no other processes. 7. Write a bash command that will start the program /home/courses/140u-doug.jones/zombie_maker as a background process,...
The first script you need to write is login.sh, a simple script that you might run...
The first script you need to write is login.sh, a simple script that you might run when you first log in to a machine. We'll expand this script later, but for now it should include your name, username, hostname, current directory, and the current time. Here is some sample output to help guide you. Note that the bolded lines that start with "[user@localhost ~]$" are the terminal prompts where you type in a command, not part of the script. Of...
Name the script for.sh.  This script will create a shopping list. Ask the user to enter items...
Name the script for.sh.  This script will create a shopping list. Ask the user to enter items separated by a space. Read the list. Use a for loop to write (use echo) the items to a file called shopping_list. You should use >> to append the output to the file, so each time the script is run the list should get longer. After the for loop finishes, display (use cat) the contents of the shopping list with 1 item per line....
1- Create a new script that is called HW9.m and save it. The script will do...
1- Create a new script that is called HW9.m and save it. The script will do the following. Test your code for each of the cases and upload your script as a .m file. [15 points] a. Create a random integer numbers that goes from 0 to 5 and assign it to a variable y using rand and round commands. Hint: Note that rand function only creates random number between 0 and 1. You need to scale the values to...
Create a file consisting a group of 3 new user name’s and passwords in powershell, 1...
Create a file consisting a group of 3 new user name’s and passwords in powershell, 1 to a line. When you read in the line you’ll have to split the name and the password. a. Write a script in powershell that does the following i. Use get-content to retrieve the names and assign them to an array ii. Write a loop that prints out each of the user names. iii. Have your script create an account using localuser for each...
Save your select statements as a script. Place the semicolon at the end of each SQL...
Save your select statements as a script. Place the semicolon at the end of each SQL statement. Please number your select statements from 1 to 8 in your script and comment out each number. Include your name and student number as a comment at the top of your script. The name of the script has to be Assignment1_JohnSmith. Instead of JohnSmith use your First Name and Last Name. Upload your script trough Blackboard. Use SQL Developer to create the My...
1. Switch to a command-line terminal (tty5) by pressing Ctrl+Alt+F5 and log in to the terminal...
1. Switch to a command-line terminal (tty5) by pressing Ctrl+Alt+F5 and log in to the terminal using the user name of root and the password of LINUXrocks!. 2. At the command prompt, type vi diskconfig.sh and press Enter to open a new file for editing called diskconfig.sh in your home directory. Why is it good form to use a .sh extension for shell scripts? 3. Enter the following text into the diskconfig.sh file. As you are typing the contents, ensure...
Create a program that generates a file of random numbers, and then prints them in neat...
Create a program that generates a file of random numbers, and then prints them in neat fashion to another file, and also saves to that file the average and standard deviation of those numbers. I) First, you would need to generate a file of random numbers that consists of N random numbers (100 < N < 1000). Each random digit should be a real number (type double) between 0 and 50. This file and its digits would now serve as...
I did already posted this question before, I did get the answer but i am not...
I did already posted this question before, I did get the answer but i am not satisfied with the answer i did the code as a solution not the description as my solution, so i am reposting this question again. Please send me the code as my solution not the description In this project, build a simple Unix shell. The shell is the heart of the command-line interface, and thus is central to the Unix/C programming environment. Mastering use of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT