Print header in tail(1)
This commit is contained in:
parent
159cc298c4
commit
d221e5ea5b
8
tail.c
8
tail.c
|
@ -24,6 +24,7 @@ main(int argc, char *argv[])
|
||||||
void (*tail)(FILE *, const char *, long) = taketail;
|
void (*tail)(FILE *, const char *, long) = taketail;
|
||||||
char *lines;
|
char *lines;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int newline, many;
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'n':
|
case 'n':
|
||||||
|
@ -41,12 +42,17 @@ main(int argc, char *argv[])
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
tail(stdin, "<stdin>", n);
|
tail(stdin, "<stdin>", n);
|
||||||
} else {
|
} else {
|
||||||
for (; argc > 0; argc--, argv++) {
|
many = argc > 1;
|
||||||
|
for (newline = 0; argc > 0; argc--, argv++) {
|
||||||
if (!(fp = fopen(argv[0], "r"))) {
|
if (!(fp = fopen(argv[0], "r"))) {
|
||||||
weprintf("fopen %s:", argv[0]);
|
weprintf("fopen %s:", argv[0]);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (many)
|
||||||
|
printf("%s==> %s <==\n",
|
||||||
|
newline ? "\n" : "", argv[0]);
|
||||||
|
newline = 1;
|
||||||
tail(fp, argv[0], n);
|
tail(fp, argv[0], n);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user