Week Four Tutorial Exercises 1. Write a program called valid that outputs to standard out "yes" if its argument is a valid shell variable and "no" otherwise.(Note: just check the syntax - begins with letter or underscore, etc) eg.
$ valid var_name
yes
$ valid 123
no                                                                                                  (Kochan and Wood P186)  
2. Write a program called am-or-pm that displays the time of day in am or pm notation, rather than 24 hour clock time. 
    (Use expr to convert from 24 hour clock time).
eg.
$ date
Mon Jun 21 20:04:50 EDT 1993
$ am-or-pm
10:04 pm
   Rewrite using a case command instead.                                            (Kochan and Wood P186)

3(a). Write a shell program called wgrep that searches a file for a given pattern, just as grep does. 
        For each line in the file that matches, print a "window" around the matching line. 
        That is, print the line preceding the match, the matching line and the line following the match. 
        Be sure to properly handle the special cases where the pattern matches the first line of the file, 
       and where the pattern matches the last line of the file.

(b). Modify wgrep to take an optional -w option that specifies the window size; so

wgrep -w 3 UNIX text       should print three lines before and three lines after each line from text that contains the pattern UNIX.
(c). Modify wgrep to take a variable number of filenames as arguments. 
Precede each output line with the name of the file in which the match occurs (as grep does).
(Kochan and Wood P 214)
 
4. Write a shell script called Trash that can be used to remove files by placing them 
in a directory called ".trash" in your HOME directory.

5. Modify your solution to Q41 so that the name and location of the ".trash" directory is specified by 
the value of the shell variable called "TRASH". If TRASH is null or doesn’t exist then it should assume
 default value of "$HOME/.trash".

6. Write a shell script called TimenDate that displays the correct date information in the order of 
Time of day, Day of week, Day number, Month name and 4 digit year. 
For example: 16:48:12 Wed 8 Dec 1998

7. Write a script that displays the type of a file whose name is given as a command-line parameter. 
The type of the file should be: An ordinary file, a Directory or Something else.