summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2022-05-12 15:15:28 +0200
committerAlejandro Colomar <alx.manpages@gmail.com>2022-05-12 15:15:28 +0200
commit20a93ba2943096b6f0c1fbb58ecdcc48e90e25f4 (patch)
tree3b22984c14e14849c9f0048d3709db7eac55eeeb
parent9d731d282c3eb7b7b6cb192c0b19e3702c6cd658 (diff)
grepc, grepc.1: Add -k option for a more compact output
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
-rwxr-xr-xbin/grepc14
-rw-r--r--share/man/man1/grepc.15
2 files changed, 16 insertions, 3 deletions
diff --git a/bin/grepc b/bin/grepc
index e829a7c..edfe93f 100755
--- 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';
}
diff --git a/share/man/man1/grepc.1 b/share/man/man1/grepc.1
index c459510..8bae0ee 100644
--- a/share/man/man1/grepc.1
+++ b/share/man/man1/grepc.1
@@ -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