Answered step by step
Verified Expert Solution
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 ~Documentscislabsh that:
Finds the most recent and least recent in separate stepsx 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, files here
one file for the complete results of all files in the directory, name the variable $completeresults
one file for the top x results most recent name the variable $topresults
one file for the bottom x results least recent name the variable $bottomresults
Take in from the user prompt and read response the directory where the output files will be located. Name this variable $outputdir
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, $completeresults.
Output only the top x results and write that to another file, $topresults.
Output only the bottom x results and write that to another file, $bottomresults.
Special notes:
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
Make sure your script works! If it doesn't run it doesn't you're not done!
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 assignment since you can check and test everything :)
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.
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started