You will write a shell script that calculates the following information for the contents of a given directory. The directory is to be specified as a single command line argument to your script. You do not need to account for any contents of nested subdirectories -- just the direct contents of the specified directory.
The total number of directories that are in the given directory (note that these are subdirectories).
The number of items (files/directories) in the given directory that are readable.
The number of items (files/directories) in the given directory that are writable.
The number of items (files/directories) in the given directory 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 extCheckFiles.sh
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:
Usage: extCheckFiles.sh
Your script must also check that the command line argument exists and is a directory. If it is not, then output an appropriate error message, and end the script processing.
Example: The user enters the command:
extCheckFiles.sh tempDir
If tempDir is not a valid directory, then output:
tempDir: No such directory