|
Assignment
Your second bash assignment is to make a script that will accept a
filename as it's argument and print the contents.
If the file
specified does not exist, your script should print an appropriate error
message. If no filename is given as an argument, your script should print
an appropriate error message.
Details
- Your script will contain 2 if-then statements to handle the two
possible errors. One if-then will check to see if the correct number of
arguments was passed to the script (1). The second if-then will check to
see if the file exists.
Tips
- The arguments passed to the script are numbered $1, $2, ...
- if [ -e $somefile ] will test if
$somefile file exists.
- $# holds the number of arguments passed
A solution
|