diff options
author | Alejandro Colomar <alx@kernel.org> | 2023-11-05 03:12:53 +0100 |
---|---|---|
committer | Alejandro Colomar <alx@kernel.org> | 2023-11-05 13:00:12 +0100 |
commit | 6fc13c5479d9c71ab3a4be86a6e1593868ca8b3e (patch) | |
tree | 6113a5b12167bc46486a5a58feee699aa5b16f6f | |
parent | d9d77953bb80b498b83850b6a756aa72cca6cd82 (diff) |
bin/grepc, grepc.1: -n: Add option to control printing of line numbers
Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rwxr-xr-x | bin/grepc | 8 | ||||
-rw-r--r-- | share/man/man1/grepc.1 | 6 |
2 files changed, 11 insertions, 3 deletions
@@ -10,6 +10,7 @@ h='-H'; i=''; k='no'; l=''; +n=''; t='no'; t_e='no'; t_fp='no'; @@ -43,7 +44,7 @@ grepc_err() grepc_parse_cmd() { - while getopts "A:B:C:chiklt:" opt; do + while getopts "A:B:C:chiklnt:" opt; do case "$opt" in A) A="-A$OPTARG"; @@ -70,6 +71,9 @@ grepc_parse_cmd() l='-l'; k='yes'; ;; + n) + n='-n'; + ;; t) case "$OPTARG" in e) @@ -254,7 +258,7 @@ grepc_search() opts="$opts $i"; opts="$opts $l"; opts="$opts -M"; - opts="$opts -n"; + opts="$opts $n"; if test -z "$files"; then pcre2grep $opts -f "$patterns"; diff --git a/share/man/man1/grepc.1 b/share/man/man1/grepc.1 index ac124f3..f1ff4eb 100644 --- a/share/man/man1/grepc.1 +++ b/share/man/man1/grepc.1 @@ -162,6 +162,10 @@ instead print the name of each input file from which output would normally have been printed. Each file is only printed once. .TP +.B \-n +Prefix each line of output with the +1-based line number within its input file. +.TP .BI \-t " type" Restrict the search to a specific .I type @@ -185,7 +189,7 @@ If you need to read a non-seekable file, redirect it to the standard input. .SH EXAMPLES .EX -.RB \(ti/src/nginx/unit$ " grepc nxt_sprintf .;" +.RB \(ti/src/nginx/unit$ " grepc \-n nxt_sprintf .;" \& \& \&./src/nxt_sprintf.h:15: |