diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2022-05-11 19:51:46 +0200 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2022-05-11 21:19:37 +0200 |
commit | 4c4f042196f907f42fd06612c7037716246ae5ae (patch) | |
tree | 4ae33fdc3425cff554660e8c1041496427d8df5c /bin | |
parent | 06a6f7b4582fcf0209d0b78b267ca5daab2a6731 (diff) |
grepc, grepc.1: -x: Add option to edit file extension
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/grepc | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -1,20 +1,27 @@ #!/bin/sh +# Defaults: +ext='\.[ch]$'; + + grepc_usage() { - echo "Usage: $0 [OPTION] IDENTIFIER"; + echo "Usage: $0 [OPTION ...] IDENTIFIER"; } grepc_parse_cmd() { - while getopts "h" opt; do + while getopts "hx:" opt; do case "$opt" in h) grepc_usage; exit 0; ;; + x) + ext="$OPTARG"; + ;; ?) grepc_usage >&2; exit 1; @@ -36,7 +43,7 @@ grepc_find_files() files="$(mktemp -t 'grepc.XXXXXX')"; find . -type f \ - | grep -P '\.[ch]' \ + | grep -P "$ext" \ | xargs grep -lPI "$1\b" \ >"$files"; } |