Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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:

assignment6.sh abcd

abcd: 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 date

Sample Runs

Gaitros:> assignment6.sh

Usage: assignment6.sh

Gaitros:> assignment6.sh ABCD

ABCD: no such directory

Gaitros:> assignment6.sh tempdir

Statistics on the directory tempdir

Number of Directories: 1

Number of Files: 15

Number of Readable files: 13

Number of Writeable files: 13

Number of Executable Files: 15

Gaitros:>assignment6.sh ~gaitrosd

Statistics on the directory /home/faculty/gaitrosd

Number of Directories: 1

Number of Files: 174

Number of Readable files: 174

Number of Writeable files: 174

Number of Executable Files: 157image text in transcribed

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. The number of items (files/directories) in the directory(passed as a parameter) that are executable. 5. 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

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

=+ Why do we have markets and, according to economists,

Answered: 1 week ago