--- tail.c 2005-11-02 08:18:47.000000000 -0500 +++ tail.c 2005-12-06 17:52:30.000000000 -0500 @@ -152,6 +152,9 @@ /* If true, count from start of file instead of end. */ static bool from_start; +/* Does input start with the 1st line or the 0th? */ +static int first_unit = 1; + /* If true, print filename headers. */ static bool print_headers; @@ -210,6 +213,7 @@ {"silent", no_argument, NULL, 'q'}, {"sleep-interval", required_argument, NULL, 's'}, {"verbose", no_argument, NULL, 'v'}, + {"zero", no_argument, NULL, 'z'}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, {NULL, 0, NULL, 0} @@ -267,6 +271,7 @@ -s, --sleep-interval=S with -f, sleep for approximately S seconds\n\ (default 1.0) between iterations.\n\ -v, --verbose always output headers giving file names\n\ + -z, --zero count input lines or bytes from zero\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); @@ -1450,7 +1455,7 @@ { int c; - while ((c = getopt_long (argc, argv, "c:n:fFqs:v", long_options, NULL)) + while ((c = getopt_long (argc, argv, "c:n:fFqs:vz", long_options, NULL)) != -1) { switch (c) @@ -1544,6 +1549,10 @@ *header_mode = always; break; + case 'z': + first_unit = 0; + break; + case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); @@ -1606,11 +1615,8 @@ /* To start printing with item N_UNITS from the start of the file, skip N_UNITS - 1 items. `tail -n +0' is actually meaningless, but for Unix compatibility it's treated the same as `tail -n +1'. */ - if (from_start) - { - if (n_units) - --n_units; - } + if (from_start && n_units) + n_units -= first_unit; if (optind < argc) {