Question: =========== Exercise 01 =========== Create a script called ex01.sh. This script should check the number of command line arguments. If there are 2 or more
=========== Exercise 01 ===========
Create a script called ex01.sh. This script should check the number of command line arguments. If there are 2 or more is should print the message:
CORRECT USAGE
and terminate with a return code of 0
If there are less than 2 command line arguments, it should print the message:
INCORRECT USAGE
and terminate with a return code of 123
=========== Exercise 02 ===========
Create a script called ex02.sh that behaves as follows:
1) If there is 1 command line arguments, the script should print the message "usage: ex02.sh max|min|sum v1 [v2 ...]" and exit with an error code of 1.
2) If there are one or more command line arguments, the first argument must be either "min", "max" or "sum", if it is none of these, the script should print "ERROR: invalid command:
3) Command line arguments after the first one should be treated as integers. If the "max" command was given, the script should print the message "MAX:
=========== Exercise 03 ===========
Create a script called ex03.sh that behaves as follows:
1) It should accept a single command line argument. If there are zero or more than one argument it should print the message "usage: ex03.sh
2) If the command line argument represents a regular file, the script should print out the symbolic file permissions for the file's owner, in upper-case and then exit with return code 0. For example, if the file was readable and executable by the owner, the script should output "R-X". Use the output from ls, cut and the tr command to get these permissions, you should not need a bunch of if statements.
3) If the command line argument is not a regular file, the script should print out: "invalid argument:
=========== Exercise 04 ===========
Create a script called ex04.sh that behaves as follows:
1) It should accept two command line arguments. If any other number of arguments is passed in it should print the message "usage: ex04.sh
2) The script should do a case insensitive comparison of the first two arguments and if they match, exit with return code 0, otherwise exit with a return code of 1. There should be no output on standard output from this script.
=========== Exercise 05 ===========
Create a script called ex05.sh that behaves as follows:
1) It should accept a single command line argument. If it is invoked with any other number of arguments, it should print a message "usage: ex05.sh
2) If the first argument is not a directory, the script should exit with the message "invalid path:
3) Loop across all of the directories below the specified directory and take the following actions:
a) If the directory does not have any files (directories are ok) other than a file called EMPTY the script should create a zero byte file called EMPTY in that directory. If the EMPTY file exists, but does not have zero bytes, it should be removed and replaced with a zero byte one.
b) Otherwise, the script should create a file called NONEMPTY that contains only the number of files in that directory excluding the NONEMPTY file (and excluding any directories).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
