Add a -q option to suppress header lines when multiple files are specified.
Approved by: cperciva (mentor) MFC after: 1 week
This commit is contained in:
parent
1de763bd77
commit
aa1d7ce72f
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user