CMPSCI 197J: HW4

  NAME: ..........................................                        DUE DATE: Jan 19, 1999
     
    1.                                                                                                       (10 points)
    List the name of each file in the current directory(or any subdirectory of it)  which is a regular file, together with the first line of the file.
    A regular file is essentially one which is not a directory.

    2.                                                                                                      (10 points)
    Write a script which will take text input from standard input, and copy it to standard output with each line preceded by a line number in the same manner as cat -n. Do not use the command cat.

    3.                                                                                                      (10 points)
    Write a script called saytime which will print out the current time in words.

    4.                                                                                                       (20 points)
    Write a function changedir which will prompt you for a directory name and cd to that directory. Why must you use a function, and not a script?

    5.                                                                                                        (20 points)
    Write a script which will every minute display the date and time, but when run in the foreground will terminate if it receives ctrl-C 3 times.

    6.                                                                                                        (30 points)
    Write a script called pythagoras which will take two numerical arguments, representing the base length and the height of a right-angled triangle, plus one or two options -a and -h(meaning area and help). With option -a, the area of the triangle will be printed on standard output preceded by the  message AREA is, and with option -h a short help message will be printed. With no options, there will be no output; any other option will be ignored, except that a warning message will be output on standard error.