Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Linux bash shell please. In this shell script you will take some input from the user and use that input to find files and send

Linux bash shell please.
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/cis190/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.
Special notes:
1.Make sure to enclose your variable names in "" or else your script will not function correctly with directory names that have spaces in them. Test your script on directories with spaces in the name and ensure it works, I will when I grade it! If your script doesn't work with spaces in the names it will not be eligible for more than a 70%!
2.Make sure your script works! If it doesn't run it doesn't you're not done!
3.Run your script in debug mode and make sure line by line it is doing what you want it to do. This assignment should be a 100% assignment since you can check and test everything :)
4.If you don't understand what is supposed to be done logically post a question to the Discord group and we'll discuss it. You can only do the task correctly if you understand what the task is so make sure you are clear.
5.Submit a copy of your script file to this assignment and leave a copy in the specified directory.

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 Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions