Print header in head(1)
This commit is contained in:
parent
2a84dd5076
commit
93c8aaf925
8
head.c
8
head.c
|
@ -21,6 +21,7 @@ main(int argc, char *argv[])
|
|||
long n = 10;
|
||||
FILE *fp;
|
||||
int ret = 0;
|
||||
int newline, many;
|
||||
|
||||
ARGBEGIN {
|
||||
case 'n':
|
||||
|
@ -36,12 +37,17 @@ main(int argc, char *argv[])
|
|||
if (argc == 0) {
|
||||
head(stdin, "<stdin>", n);
|
||||
} else {
|
||||
for (; argc > 0; argc--, argv++) {
|
||||
many = argc > 1;
|
||||
for (newline = 0; argc > 0; argc--, argv++) {
|
||||
if (!(fp = fopen(argv[0], "r"))) {
|
||||
weprintf("fopen %s:", argv[0]);
|
||||
ret = 1;
|
||||
continue;
|
||||
}
|
||||
if (many)
|
||||
printf("%s==> %s <==\n",
|
||||
newline ? "\n" : "", argv[0]);
|
||||
newline = 1;
|
||||
head(fp, argv[0], n);
|
||||
fclose(fp);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user