Question: Lab Assignment 12 In this shell script you will take some input from the user and use that input to find files and send the

Lab Assignment 12

In this shell script you will take some input from the user and use that input to find files and send the matching output to files. This is a task that would be common in managing users. We will find files that are the most and least recently edited. In this script you will use only the if control structure, no loops will be used. It is recommended to write out on paper the logical steps necessary to achieve the tasks of this script. It is much easier and quicker to do this on paper and then translate it into bash script later. Most of you will ignore this advice and spend more time and frustration than necessary, you have been advised ;)

Write a shell script (~/Documents/cis90/lab12.sh) that:

Finds the most recent (and least recent in separate steps) "x" number of edited files in directory "y" where x and y are positional parameters passed from the user to the script during execution of the script.

Take in from the user (prompt and read response) the target file names, 3 files here

one file for the complete results of all files in the directory, name the variable $complete_results

one file for the top x results (most recent), name the variable $top_results

one file for the bottom x results (least recent), name the variable $bottom_results

Take in from the user (prompt and read response) the directory where the output files will be located. Name this variable $output_dir

Creates variables $x and $y to assign the shell parameters to

Uses the $x and $y variables instead of the shell parameters thereafter in the program

Has comments explaining:

the purpose of the script

the variables used and if those variables are required or optional

The script must test for valid input on each of the fields. If the input isn't valid report the error back to the user and exit the script.

Output the complete results to a file, $complete_results.

Output only the top "x" results and write that to another file, $top_results.

Output only the bottom "x" results and write that to another file, $bottom_results.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!