Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 . For each problem, submit 1 ) your program and 2 ) screenshots ( jpg or png format ) of the execution ( command
For each problem, submit your program and screenshots jpg or png format of the execution command line and output of the program. Check homework policies in the syllabus for details.
Include appropriate comments in your code to describe the functionality of different sections. This helps the grader understand and determine the correctness of your code.
Name your scripts and screenshots clearly, so that the grader knows which files are for which problem. For example, for problem you may name the files as scriptsh and screenshotjpg or screenshotjpg and screenshotjpg if you submit two screenshots
Submit individual files. DO NOT SUBMIT A ZIP FILE.
The final submission must be your individual work. Copying or reengineeringparaphrasing code that was not developed by you is strictly prohibited. The use of AIbased code generators is prohibited.
Problem :
Write a Bash script that performs the following steps:
Prompts the user for a pathname of a directory, verifies the directory exists, and moves into that directory.
Lists all the files in the directory and displays a menu to the user to select a file.
After a file is selected, display the last ten lines of the file and ask the user if they want to display more. If the user responds "yes", display the next ten lines.
Continue displaying the next ten lines at a time as long as the user responds "yes". Stop "scrolling up if the displaying reaches the first line of the file.
Problem :
Write a Bash script, which prints out the entries including files and subdirectories in a directory in a reversed order as what obtained using filename expansion. The pathname of the directory is provided as an argument. Assuming that with filename expansion you see mydir contains "cache cron games lib log run tmp your program "reverse.sh mydir will print tmp run log lib games cron cache." You can print the names on one line, or each name on a line.
Use filename expansion, array, and at least one function reverse Your script should be able to correctly handle the entries with spaces in their names. For example, if a file is named "bash scripting.ppt make sure that your script does not break the name into two parts: "bash" and "scripting.ppt
DO NOT use the builtin command "sort r or ls r
Problem :
Write a Bash script, which sorts a list of command line parameters in ascending order. For example, your command will look something like:
$ insertsort.sh
and type enter.
Your program will return:
Use only basic commands and array. Do not use any builtin commands that sort array.
Problem :
Write a Bash script, which builds a table of counters for the files under bin based on the first character in their filenames. For example, if there are no files with filenames starting with a files with their names starting with b and files with their names starting with z the script would print
a
b
z
Use a loop to iterate through az Use an associative array to contain the counts. Print out the characters and the counts at the end of the script.
Note that your script must report the real numbers for the file names starting with lower case letters from a to z There are no requirements on reporting numbers for other characters symbols such as digits, or upper case letters
Problem :
Write a Bash script that traverses a directory provided as a commandline argument and finds all duplicate filenames files having the same name, not necessarily the same directory or contents File name extension is considered as a part of filename.
Every time when the script finds a filename, which is a duplicate of another filename, the script should print out the pathnames of the duplicate files both files ask the user if they want to remove the newly found file, and delete the file if the user confirms the deletion.
You may use basename to strip directories and get only filenames from pathnames.
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