aboutsummaryrefslogtreecommitdiff
path: root/etc/g
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-07-12 13:24:49 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-07-12 13:27:07 +0200
commit03d827e2fbc409ef97829f25b8eeca5204f81a3c (patch)
tree6099f0feb9adf3425fba87549b164043e18bd0c7 /etc/g
parent45cddd072119c5abd7ec076cf28d51ee01f125b7 (diff)
downloadxutil-03d827e2fbc409ef97829f25b8eeca5204f81a3c.tar.gz
Re-organize files
Diffstat (limited to 'etc/g')
-rwxr-xr-xetc/g30
1 files changed, 30 insertions, 0 deletions
diff --git a/etc/g b/etc/g
new file mode 100755
index 0000000..7c55707
--- /dev/null
+++ b/etc/g
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+# g -- poor man's ack
+
+IFS='
+'
+
+pat=
+opt=
+i=0
+
+while [ $((i++)) -lt $# ]; do
+ case "$1" in
+ -*) opt=`printf '%s%s\n' "$opt" $1`
+ shift ;;
+ *) break ;;
+ esac
+done
+
+[ $# -eq 0 ] && { echo usage: $0 [-...] pattern [file ...] 1>&2; exit 1; }
+
+pat=$1
+shift
+
+files=`find . -name '*.c' -or -name '*.h' -or -name '*.cc' | sed s,./,,`
+[ -z "$files" ] && [ -z "$*" ] && { echo no matching files found 1>&2; exit 1; }
+
+# todo (?): treat argument \*.x like -or -name \*.x
+
+p grep $opt -n "$pat" $files "$@"