From ae62197f6a0124fd6428d42a501e11cee68e6182 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 25 Jan 2009 16:09:23 +0100 Subject: Add -q, --quiet and --silent options inotail should become option compatible to GNU tail. --- inotail.1 | 21 ++++++++++++--------- inotail.c | 13 ++++++++++--- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/inotail.1 b/inotail.1 index d543e52..d349253 100644 --- a/inotail.1 +++ b/inotail.1 @@ -2,14 +2,14 @@ .\" ** The above line should force tbl to be a preprocessor ** .\" Man page for inotail .\" -.\" Copyright (c) 2006 Tobias Klauser +.\" Copyright (c) 2006-2009 Tobias Klauser .\" .\" You may distribute under the terms of the GNU General Public .\" License as specified in the file COPYING that comes with .\" inotail. .pc -.TH INOTAIL 1 "2006-08-13" "" "Inotify enhanced tail" +.TH INOTAIL 1 "2009-01-25" "" "Inotify enhanced tail" .SH NAME inotail \- A fast and lightweight version of tail using inotify .SH SYNOPSIS @@ -30,24 +30,27 @@ Currently inotail is not fully compatible to neither POSIX or GNU tail but might be in the future. .SH OPTIONS .TP -.B \-c \fIN\fR, \fB\-\-bytes\fR=\fIN\fR +.B \-c \fIN\fR, \fB\-\-bytes\fR=\fIN output the last N bytes. If the first character of N is a '+', begin printing with the Nth character from the start of each file. .TP -.B \-f, \fB\-\-follow +.B \-f\fR, \fB\-\-follow keep the file(s) open and print appended data as the file grows .TP -.B \-n \fIN\fR, \fB\-\-lines\fR=\fIN\fR +.B \-n \fIN\fR, \fB\-\-lines\fR=\fIN output the last N lines (default: 10) If the first character of N is a '+', begin printing with the Nth line from the start of each file. .TP -.B \-v, \fB\-\-verbose -print headers with file names +.B \-q\fR, \fB\-\-quiet\fR, \fB\-\-silent +never print headers with file names .TP -.B \-h, \fB\-\-help +.B \-v\fR, \fB\-\-verbose +alway print headers with file names +.TP +.B \-h\fR, \fB\-\-help show help and exit .TP -.B \-V, \fB\-\-version +.B \-V\fR, \fB\-\-version show inotail version and exit .SH AUTHOR .PP diff --git a/inotail.c b/inotail.c index 9bb126d..5ecfcf4 100644 --- a/inotail.c +++ b/inotail.c @@ -49,9 +49,11 @@ static int n_ignored = 0; static const struct option long_opts[] = { { "bytes", required_argument, NULL, 'c' }, { "follow", optional_argument, NULL, 'f' }, + { "help", no_argument, NULL, 'h' }, { "lines", required_argument, NULL, 'n' }, + { "quiet", no_argument, NULL, 'q' }, + { "silent", no_argument, NULL, 'q' }, { "verbose", no_argument, NULL, 'v' }, - { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { NULL, 0, NULL, 0 } }; @@ -74,7 +76,9 @@ static void usage(const int status) " -c N, --bytes=N output the last N bytes\n" " -f, --follow output as the file grows\n" " -n N, --lines=N output the last N lines (default: %d)\n" - " -v, --verbose print headers with file names\n" + " -q, --quiet, --slient\n" + " never print headers with file names\n" + " -v, --verbose always print headers with file names\n" " -h, --help show this help and exit\n" " -V, --version show version and exit\n\n" "If the first character of N (the number of bytes or lines) is a `+',\n" @@ -717,7 +721,7 @@ int main(int argc, char **argv) char **filenames; struct file_struct *files = NULL; - while ((c = getopt_long(argc, argv, "c:n:fvVh", long_opts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "c:n:fqvVh", long_opts, NULL)) != -1) { switch (c) { case 'c': mode = M_BYTES; @@ -738,6 +742,9 @@ int main(int argc, char **argv) case 'f': forever = 1; break; + case 'q': + verbose = 0; + break; case 'v': verbose = 1; break; -- cgit v1.2.3-54-g00ecf