summaryrefslogtreecommitdiffstats
path: root/bin/grepc
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2022-05-11 19:51:46 +0200
committerAlejandro Colomar <alx.manpages@gmail.com>2022-05-11 21:19:37 +0200
commit4c4f042196f907f42fd06612c7037716246ae5ae (patch)
tree4ae33fdc3425cff554660e8c1041496427d8df5c /bin/grepc
parent06a6f7b4582fcf0209d0b78b267ca5daab2a6731 (diff)
grepc, grepc.1: -x: Add option to edit file extension
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Diffstat (limited to 'bin/grepc')
-rwxr-xr-xbin/grepc13
1 files changed, 10 insertions, 3 deletions
diff --git a/bin/grepc b/bin/grepc
index 3d78821..0bcc112 100755
--- a/bin/grepc
+++ b/bin/grepc
@@ -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";
}