ObjectiveTo practice with shell scripting, and learn the basic skills to write shell scripts thatperform simple tasks involving the monitoring of directories and files.TaskA given UNIX directory may contain many files and subdirectories. For the purpose of this assignment, a “file” is a non-directory file, and a directory is a subdirectory of the given directory. Each file or directory might have different permissions. For example, a file might have read and execute permissions for the owner. A directory might have only read permission.In this assignment, you will write a shell script that calculates the following information for the contents of a given directory. The directory that you will analyze will be passed in as a single command line argument to your script. You don’t need to account for any contents of nested subdirectories — just the direct contents of the specified directory passed in as a directory.1. The total number of directories that are in directory passed as a parameter.2. The total number of files in the given passed directory.3. The number of items (files/directories) in the directory (passed as a parameter)that are readable.4. The number of items (files/directories) in the directory (passed as a parameter)that are writable.5. The number of items (files/directories) in the directory(passed as a parameter) that are executable.Note that any hidden files or hidden directories are not included in this count. Forexample, “..”_ represents the parent directory of the current directory and is not counted as a directory or as a file. Similarly, “.login”_ would not be counted. Only regular files and directories in the given directory are calculated.Requirements• The script should be named assignment6.sh• The script must be written to run under the bash shell!• Your script must check for the correct number of arguments (one argument). Ifsomebody tries to invoke the script without passing in the correct number ofarguments, then output this usage message and abort the script:Usage: assignment6.sh <directory_name• Your script must also check that the command line argument actually exists and is a valid directory (any directory). If it is not, then output an appropriate error message, and end the script processing. Example: If the user inputs a parameterthat is not a directory you should issue the following message:assignment6.sh abcdabcd: No such directory• The script should print all of its results to standard output• Include comments at the top of your script file, which specify your name, the course (COP 3353), the assignment number, and the dateSample RunsGaitros: assignment6.shUsage: assignment6.sh <directoryGaitros: assignment6.sh ABCDABCD: no such directoryGaitros: assignment6.sh tempdirStatistics on the directory tempdirNumber of Directories: 1Number of Files: 15Number of Readable files: 13Number of Writeable files: 13Number of Executable Files: 15Gaitros:assignment6.sh ~gaitrosdStatistics on the directory /home/faculty/gaitrosdNumber of Directories: 1Number of Files: 174Number of Readable files: 174Number of Writeable files: 174Number of Executable Files: 157SubmittingSubmissionGo to the Blackboard site (campus.fsu.edu) and login to your account and access the COP3353 portal. Select Assignments and select Assignment6. Follow the directions for submitting an assignment on Blackboard. You need to submit the file assignment6.shfor this assignment. You can make up to 5 submissions and the last submission will be graded.
Programming
[Solved] Assignment #6 Basic Shell scripting with control structures
30 $
File Name: Assignment_#6_Basic_Shell_scripting_with_control_structures.zip
File Size: 555.78 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.