Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4 Simple Scripting 40 pts] Please submit your solutions as shell scripts for this question. For example, create a file named q4_pl.sh for Part 1.

image text in transcribed

4 Simple Scripting 40 pts] Please submit your solutions as shell scripts for this question. For example, create a file named q4_pl.sh for Part 1. There is no specific input/output format other than the ones stated in the questions. 4.1 Part 1 [12 pts] Write a script using simple shell commands. The script takes a command line argument that specifies a directory dir. The script first changes directory to dir, then prints the following in sequence: 1. A line starting "Current username is: ". Then on the same line, the current username. 2. A line starting "Current directory is ". Then, on the same line, the absolute pathname of the current working directory. 3. A line starting "Home directory is: ". Then, on the same line, the absolute pathname of the home directory 4. An empty line 5. The line . . 5 most recently modified directories with rwxrwxrwx- 6. the 5 most recently modified subdirectories with rwxrwxrwx permission in the current directory in long listing format (most recent first) 7. An empty line 8. The line "-Files in last 30-60 minutes" 9. The files in the current directory that are modified more than 30 minutes ago, but less than 60 minutes ago 10. An empty line, followed by a line of 70 equal signs Run your script three times, with three different input directories. Append the output of each script execu tion to a file called q4_pl.txt Note that you may assume that there are at least 5 directories in an input directory 4.2 Part 2 [8 pts Create 10 directories using a for loop in Bash. Submit the shell script your created. Even numbered directories should be named even2, even4, even6, even8 and even10 and should have rw-rw-r permissions while the odd numbered directories should be named oddl, odd3, odd5, odd7 and odd9 and should have r-r-r- permissions. 4.3 Part 3 (6 pts] Write a shell script that prompts the user to enter a sentence, and prints the number of letters and words in the sentence 4.4 Part 4 [6 pts Write a shell script that counts the number of .sh files under a directory provided as a command line parameter without using the ls command, then prints the number to the screen. 4.5 Part 5 |8 pts] Write a shell script that takes a list of numbers as command-line parameters(e.g., q4 _p5.sh 4 221 6), and calculates min, max and mean of these numbers. Note: Number of command-line parameters is dynamic. 4 Simple Scripting 40 pts] Please submit your solutions as shell scripts for this question. For example, create a file named q4_pl.sh for Part 1. There is no specific input/output format other than the ones stated in the questions. 4.1 Part 1 [12 pts] Write a script using simple shell commands. The script takes a command line argument that specifies a directory dir. The script first changes directory to dir, then prints the following in sequence: 1. A line starting "Current username is: ". Then on the same line, the current username. 2. A line starting "Current directory is ". Then, on the same line, the absolute pathname of the current working directory. 3. A line starting "Home directory is: ". Then, on the same line, the absolute pathname of the home directory 4. An empty line 5. The line . . 5 most recently modified directories with rwxrwxrwx- 6. the 5 most recently modified subdirectories with rwxrwxrwx permission in the current directory in long listing format (most recent first) 7. An empty line 8. The line "-Files in last 30-60 minutes" 9. The files in the current directory that are modified more than 30 minutes ago, but less than 60 minutes ago 10. An empty line, followed by a line of 70 equal signs Run your script three times, with three different input directories. Append the output of each script execu tion to a file called q4_pl.txt Note that you may assume that there are at least 5 directories in an input directory 4.2 Part 2 [8 pts Create 10 directories using a for loop in Bash. Submit the shell script your created. Even numbered directories should be named even2, even4, even6, even8 and even10 and should have rw-rw-r permissions while the odd numbered directories should be named oddl, odd3, odd5, odd7 and odd9 and should have r-r-r- permissions. 4.3 Part 3 (6 pts] Write a shell script that prompts the user to enter a sentence, and prints the number of letters and words in the sentence 4.4 Part 4 [6 pts Write a shell script that counts the number of .sh files under a directory provided as a command line parameter without using the ls command, then prints the number to the screen. 4.5 Part 5 |8 pts] Write a shell script that takes a list of numbers as command-line parameters(e.g., q4 _p5.sh 4 221 6), and calculates min, max and mean of these numbers. Note: Number of command-line parameters is dynamic

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

Step: 3

blur-text-image

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

Students also viewed these Databases questions