]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
bin/grepc, grepc.1: -n: Add option to control printing of line numbers
authorAlejandro Colomar <alx@kernel.org>
Sun, 5 Nov 2023 02:12:53 +0000 (03:12 +0100)
committerAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 20:29:21 +0000 (21:29 +0100)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
bin/grepc
share/man/man1/grepc.1

index f37510d372884bf3c742169e1db1a68e2eda33af..23de67d37f749faaf75a40da434913ea502f8b1d 100755 (executable)
--- a/bin/grepc
+++ b/bin/grepc
@@ -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";
index ac124f36af54126a535e86ed63cf42e5c18e8aa9..f1ff4eb6c670404153a61d437853fa91a44e8f2d 100644 (file)
@@ -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: