adjusted per comments from uwe, to match head (and gnu) code copied matching head.
add options to tail: -q (never print header of filename) -v (always print header of filename) same as head, same as gnu tail add tac which is like tail -rq
Index: Makefile =================================================================== RCS file: /cvsroot/src/usr.bin/tail/Makefile,v retrieving revision 1.3 diff -u -r1.3 Makefile --- Makefile 23 Nov 1994 07:41:55 -0000 1.3 +++ Makefile 1 Oct 2017 17:03:33 -0000 @@ -1,7 +1,8 @@ # $NetBSD: Makefile,v 1.3 1994/11/23 07:41:55 jtc Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 - PROG= tail SRCS= forward.c misc.c read.c reverse.c tail.c +LINKS= ${BINDIR}/tail ${BINDIR}/tac + .include <bsd.prog.mk> Index: tail.1 =================================================================== RCS file: /cvsroot/src/usr.bin/tail/tail.1,v retrieving revision 1.17 diff -u -r1.17 tail.1 --- tail.1 4 Jul 2017 07:04:50 -0000 1.17 +++ tail.1 1 Oct 2017 17:03:33 -0000 @@ -32,7 +32,7 @@ .\" .\" @(#)tail.1 8.1 (Berkeley) 6/6/93 .\" -.Dd June 15, 2014 +.Dd October 1, 2017 .Dt TAIL 1 .Os .Sh NAME @@ -43,7 +43,7 @@ .Oo .Fl f | .Fl F | -.Fl r +.Fl rqv .Oc .Oo .Fl b Ar number | @@ -133,12 +133,17 @@ option is to display all of the input. .El .Pp -If more than a single file is specified, each file is preceded by a +If more than a single file is specified, or the +.Fl v +option is used, each file is preceded by a header consisting of the string .Dq ==> XXX \*[Le]= where .Dq XXX is the name of the file. +The +.Fl q +flag disables the printing of the header in all cases. .Sh EXIT STATUS .Ex -std tail .Sh SEE ALSO Index: tail.c =================================================================== RCS file: /cvsroot/src/usr.bin/tail/tail.c,v retrieving revision 1.17 diff -u -r1.17 tail.c --- tail.c 31 Jan 2013 23:09:06 -0000 1.17 +++ tail.c 1 Oct 2017 17:03:33 -0000 @@ -67,6 +67,8 @@ enum STYLE style; int ch, first; char *p; + int qflag = 0; + int vflag = 0; setprogname(argv[0]); off = 0; @@ -105,30 +107,45 @@ obsolete(argv); style = NOTSET; - while ((ch = getopt(argc, argv, "Fb:c:fn:r")) != -1) - switch(ch) { - case 'F': - fflag = 2; - break; - case 'b': - ARG(512, FBYTES, RBYTES); - break; - case 'c': - ARG(1, FBYTES, RBYTES); - break; - case 'f': - fflag = 1; - break; - case 'n': - ARG(1, FLINES, RLINES); - break; - case 'r': - rflag = 1; - break; - case '?': - default: - usage(); - } + if (strcmp(getprogname(), "tail") == 0) { + while ((ch = getopt(argc, argv, "Fb:c:fn:rqv")) != -1) + switch(ch) { + case 'F': + fflag = 2; + break; + case 'b': + ARG(512, FBYTES, RBYTES); + break; + case 'c': + ARG(1, FBYTES, RBYTES); + break; + case 'f': + fflag = 1; + break; + case 'n': + ARG(1, FLINES, RLINES); + break; + case 'r': + rflag = 1; + break; + case 'q': + qflag = 1; + vflag = 0; + break; + case 'v': + qflag = 0; + vflag = 1; + break; + case '?': + default: + usage(); + } + } else { /* tac */ + qflag = 1; + vflag = 0; + rflag = 1; + } + argc -= optind; argv += optind; @@ -169,7 +186,7 @@ ierr(); continue; } - if (argc > 1) { + if (vflag || (qflag == 0 && argc > 1)) { (void)printf("%s==> %s <==\n", first ? "" : "\n", fname); first = 0; @@ -299,7 +316,7 @@ usage(void) { (void)fprintf(stderr, - "Usage: %s [-f | -F | -r] [-b # | -c # | -n #] [file ...]\n", + "Usage: %s [-f | -F | -rqv] [-b # | -c # | -n #] [file ...]\n", getprogname()); exit(1); }