summaryrefslogtreecommitdiffstats
path: root/usr.bin/tail
diff options
context:
space:
mode:
authorflz <flz@FreeBSD.org>2006-06-29 22:07:49 +0000
committerflz <flz@FreeBSD.org>2006-06-29 22:07:49 +0000
commit6d4f7a588c0904195e2770ce370af0d53f1ad7e2 (patch)
tree7224ff9a3a699242b905b5c633395a34bfe358bf /usr.bin/tail
parent015886f70c149c67011566acfd210ca13fcf26ee (diff)
downloadFreeBSD-src-6d4f7a588c0904195e2770ce370af0d53f1ad7e2.zip
FreeBSD-src-6d4f7a588c0904195e2770ce370af0d53f1ad7e2.tar.gz
Add a -q option to suppress header lines when multiple files are specified.
Approved by: cperciva (mentor) MFC after: 1 week
Diffstat (limited to 'usr.bin/tail')
-rw-r--r--usr.bin/tail/extern.h2
-rw-r--r--usr.bin/tail/forward.c5
-rw-r--r--usr.bin/tail/tail.111
-rw-r--r--usr.bin/tail/tail.c9
4 files changed, 19 insertions, 8 deletions
diff --git a/usr.bin/tail/extern.h b/usr.bin/tail/extern.h
index 9c45a1b..d956680 100644
--- a/usr.bin/tail/extern.h
+++ b/usr.bin/tail/extern.h
@@ -72,5 +72,5 @@ void oerr(void);
int mapprint(struct mapinfo *, off_t, off_t);
int maparound(struct mapinfo *, off_t);
-extern int Fflag, fflag, rflag, rval, no_files;
+extern int Fflag, fflag, qflag, rflag, rval, no_files;
extern const char *fname;
diff --git a/usr.bin/tail/forward.c b/usr.bin/tail/forward.c
index e8f3aaf..e7bdd05 100644
--- a/usr.bin/tail/forward.c
+++ b/usr.bin/tail/forward.c
@@ -249,7 +249,8 @@ show(file_info_t *file)
while ((ch = getc(file->fp)) != EOF) {
if (last != file && no_files > 1) {
- (void)printf("\n==> %s <==\n", file->file_name);
+ if (!qflag)
+ (void)printf("\n==> %s <==\n", file->file_name);
last = file;
}
if (putchar(ch) == EOF)
@@ -322,7 +323,7 @@ follow(file_info_t *files, enum STYLE style, off_t off)
if (file->fp) {
active = 1;
n++;
- if (no_files > 1)
+ if (no_files > 1 && !qflag)
(void)printf("\n==> %s <==\n", file->file_name);
forward(file->fp, style, off, &file->st);
if (Fflag && fileno(file->fp) != STDIN_FILENO)
diff --git a/usr.bin/tail/tail.1 b/usr.bin/tail/tail.1
index 9b8cabe..a8ef4f1 100644
--- a/usr.bin/tail/tail.1
+++ b/usr.bin/tail/tail.1
@@ -35,7 +35,7 @@
.\" @(#)tail.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd June 6, 1993
+.Dd June 29, 2006
.Dt TAIL 1
.Os
.Sh NAME
@@ -49,6 +49,9 @@
.Fl r
.Oc
.Oo
+.Fl q
+.Oc
+.Oo
.Fl b Ar number |
.Fl c Ar number |
.Fl n Ar number
@@ -114,6 +117,8 @@ option is ignored if reading from standard input rather than a file.
The location is
.Ar number
lines.
+.It Fl q
+Suppresses printing of headers when multiple files are being examined.
.It Fl r
The
.Fl r
@@ -139,7 +144,9 @@ header consisting of the string
.Dq ==> XXX <==
where
.Dq XXX
-is the name of the file.
+is the name of the file unless
+.Fl q
+flag is specified.
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO
diff --git a/usr.bin/tail/tail.c b/usr.bin/tail/tail.c
index 9162d17..387d236 100644
--- a/usr.bin/tail/tail.c
+++ b/usr.bin/tail/tail.c
@@ -60,7 +60,7 @@ static const char sccsid[] = "@(#)tail.c 8.1 (Berkeley) 6/6/93";
#include "extern.h"
-int Fflag, fflag, rflag, rval, no_files;
+int Fflag, fflag, qflag, rflag, rval, no_files;
const char *fname;
file_info_t *files;
@@ -114,7 +114,7 @@ main(int argc, char *argv[])
obsolete(argv);
style = NOTSET;
- while ((ch = getopt(argc, argv, "Fb:c:fn:r")) != -1)
+ while ((ch = getopt(argc, argv, "Fb:c:fn:qr")) != -1)
switch(ch) {
case 'F': /* -F is superset of (and implies) -f */
Fflag = fflag = 1;
@@ -131,6 +131,9 @@ main(int argc, char *argv[])
case 'n':
ARG(1, FLINES, RLINES);
break;
+ case 'q':
+ qflag = 1;
+ break;
case 'r':
rflag = 1;
break;
@@ -199,7 +202,7 @@ main(int argc, char *argv[])
ierr();
continue;
}
- if (argc > 1) {
+ if (argc > 1 && !qflag) {
(void)printf("%s==> %s <==\n",
first ? "" : "\n", fname);
first = 0;
OpenPOWER on IntegriCloud