In this assignment you will write a shell script that


Assignment

Objective

To practice with shell scripting, and learn the basic skills to write shell scripts that perform simple tasks involving the monitoring of directories and files.

Task

A 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. For example, ".."_ 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). If somebody tries to invoke the script without passing in the correct number of arguments, then output this usage message and abort the script:

Usage: assignment6.sh

• 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 parameter that is not a directory you should issue the following message.

Solution Preview :

Prepared by a verified Expert
Computer Engineering: In this assignment you will write a shell script that
Reference No:- TGS02253889

Now Priced at $40 (50% Discount)

Recommended (97%)

Rated (4.9/5)