diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2018-04-10 14:44:07 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2018-04-10 14:44:07 +0000 |
commit | 79490b9339565d0876aef29b4cdc332222eb961e (patch) | |
tree | f12e2cc1b088cb011853f60d72ce6650049c16af /usr.bin/head | |
parent | 4d40b7383a415885a25eed9ea956e44a528e585f (diff) | |
download | src-79490b9339565d0876aef29b4cdc332222eb961e.tar.gz src-79490b9339565d0876aef29b4cdc332222eb961e.zip |
Notes
Diffstat (limited to 'usr.bin/head')
-rw-r--r-- | usr.bin/head/head.1 | 14 | ||||
-rw-r--r-- | usr.bin/head/head.c | 10 |
2 files changed, 22 insertions, 2 deletions
diff --git a/usr.bin/head/head.1 b/usr.bin/head/head.1 index 9ccdf1871c20..c74983822916 100644 --- a/usr.bin/head/head.1 +++ b/usr.bin/head/head.1 @@ -28,7 +28,7 @@ .\" @(#)head.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd March 16, 2013 +.Dd April 10, 2018 .Dt HEAD 1 .Os .Sh NAME @@ -49,6 +49,18 @@ If .Ar count is omitted it defaults to 10. .Pp +The following options are available: +.Bl -tag -width indent +.It Fl c Ar bytes , Fl -bytes Ns = Ns Ar bytes +Print +.Ar bytes +of each of the specified files. +.It Fl n Ar count , Fl -lines Ns = Ns Ar count +Print +.Ar count +lines of each of the specified files. +.El +.Pp If more than a single file is specified, each file is preceded by a header consisting of the string .Dq ==> XXX <== diff --git a/usr.bin/head/head.c b/usr.bin/head/head.c index 6430f9e6c45e..10423dd96be0 100644 --- a/usr.bin/head/head.c +++ b/usr.bin/head/head.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include <ctype.h> #include <err.h> +#include <getopt.h> #include <inttypes.h> #include <stdio.h> #include <stdlib.h> @@ -64,6 +65,13 @@ static void head_bytes(FILE *, off_t); static void obsolete(char *[]); static void usage(void); +static const struct option long_opts[] = +{ + {"bytes", required_argument, NULL, 'c'}, + {"lines", required_argument, NULL, 'n'}, + {NULL, no_argument, NULL, 0} +}; + int main(int argc, char *argv[]) { @@ -74,7 +82,7 @@ main(int argc, char *argv[]) char *ep; obsolete(argv); - while ((ch = getopt(argc, argv, "n:c:")) != -1) + while ((ch = getopt_long(argc, argv, "+n:c:", long_opts, NULL)) != -1) switch(ch) { case 'c': bytecnt = strtoimax(optarg, &ep, 10); |