]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
grepc, grepc.1: Add -k option for a more compact output
authorAlejandro Colomar <alx.manpages@gmail.com>
Thu, 12 May 2022 13:15:28 +0000 (15:15 +0200)
committerAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 20:28:59 +0000 (21:28 +0100)
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
bin/grepc
share/man/man1/grepc.1

index e829a7c87834d28f606ca197d16833f281bc259b..edfe93ff8e71c7f5a72e33ee53f7d11c9721e402 100755 (executable)
--- a/bin/grepc
+++ b/bin/grepc
@@ -5,6 +5,7 @@
 git='no';
 ext='\.[ch]$';
 FILES='.';
+kflag='no';
 tflag='no';
 t_enum='no';
 t_func='no';
@@ -20,7 +21,7 @@ grepc_usage()
 
 grepc_parse_cmd()
 {
-       while getopts "ght:x:" opt; do
+       while getopts "ghkt:x:" opt; do
                case "$opt" in
                g)
                        git='yes';
@@ -29,6 +30,9 @@ grepc_parse_cmd()
                        grepc_usage;
                        exit 0;
                        ;;
+               k)
+                       kflag='yes';
+                       ;;
                t)
                        case "$OPTARG" in
                        e)
@@ -95,7 +99,11 @@ grepc_helper()
        | xargs grep -lP  "$2" \
        | sort \
        | xargs pcregrep -Mn "$3" /dev/null \
-       | sed -E 's/^[^: ]+:[0-9]+:/\n\n&\n/';
+       | if [ "$kflag" = 'no' ]; then
+               sed -E 's/^[^: ]+:[0-9]+:/\n\n&\n/';
+       else
+               cat;
+       fi;
 }
 
 
@@ -287,7 +295,7 @@ main()
        grepc_parse_cmd $@;
        grepc_find_files "$identifier";
        grepc_search "$identifier" \
-       | tail -n+3;
+       | sed -n '/./,$p';
 }
 
 
index c45951032a0fbdc698355eb9fd36cb8724a9945a..8bae0ee1476a0a0e62bfe1d2ed316c2a9c649f26 100644 (file)
@@ -58,6 +58,11 @@ Restrict the search to files tracked by git.
 .B \-h
 Output a help message and exit.
 .TP
+.B \-k
+Compact (kurz) output.
+Don't print extra newlines
+(the header is printed in the same line as the first line of a match).
+.TP
 .BI \-t " type"
 Restrict the search to a specific
 .I type