Assignment: #mytail Due: 11/11/02018 Points: 6

Specification

Write a C program that is a simplified version of the Unix tail command. Note: This cannot be a C++ program.

Syntax:  

   tail [-number_of_lines] filename 

Description:  

   Print the last 10 lines of filename to the standard 
   output stream.  
   
   The command returns EXIT_FAILURE if no filename is specified.  
   An error message is printed to the standard error stream prior 
   to terminating.

   If filename cannot be opened, then an error message is
   printed to the standard error stream and the command
   returns EXIT_FAILURE.

   If a file contains less than number_of_lines
   then the entire content of the file is printed.

The program can assume that if the number_of_lines option is used, then it's value is a valid integer.

The file mytail.in.txt, which contains 24 lines, will be used to test your program when it's submitted.

Here is example output.

   $ mytail mytail.in.txt        # prints last 10 lines
   from the standard input stream.

   A -f option can be used that displays lines as they are
   written to a file.

   Example:  tail -f log

   Prints the first 10 lines in file log, but the command
   continues to run and will display lines as they are
   appended to file log.
   ---
   $ mytail -5 mytail.in.txt     # prints last 5 lines
   Example:  tail -f log

   Prints the first 10 lines in file log, but the command
   continues to run and will display lines as they are
   appended to file log.
   ---
   $ mytail -100 mytail.in.txt   # prints entire file
   The 'tail' command displays the last 10 lines of a file.
   An option can be used to change 10 to some other number.
   The entire file is displayed if the number of lines to
   print is less than the total number of lines in the file.

   Note:  There is a 'head' command displays the first 10 lines
   of a file.  An option can be used to change 10 to some other
   number.

   Some notes about the Unix 'tail' command that are
   not part of this assignment.

   Multiple file names can be specified on the 'tail' command
   line.  If no file names are given, then 'tail' gets its input
   from the standard input stream.

   A -f option can be used that displays lines as they are
   written to a file.

   Example:  tail -f log

   Prints the first 10 lines in file log, but the command
   continues to run and will display lines as they are
   appended to file log.
   ---
   $ mytail foo
   could not open foo; errno=2
   ---
   $ mytail -5 foo
   could not open foo; errno=2