diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2022-05-12 15:15:28 +0200 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2022-05-12 15:15:28 +0200 |
commit | 20a93ba2943096b6f0c1fbb58ecdcc48e90e25f4 (patch) | |
tree | 3b22984c14e14849c9f0048d3709db7eac55eeeb /bin/grepc | |
parent | 9d731d282c3eb7b7b6cb192c0b19e3702c6cd658 (diff) |
grepc, grepc.1: Add -k option for a more compact output
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Diffstat (limited to 'bin/grepc')
-rwxr-xr-x | bin/grepc | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -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'; } |