aboutsummaryrefslogtreecommitdiff
path: root/bin/rgl
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-09-08 00:21:22 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-09-08 00:21:22 +1200
commit579b420b53f66a41c66d7aa1312933cd66fa9bb0 (patch)
tree644437a3edccbee07376ec4075dfe19c6c9d506e /bin/rgl
parentFix a backdated manual page (diff)
downloaddotfiles-579b420b53f66a41c66d7aa1312933cd66fa9bb0.tar.gz
dotfiles-579b420b53f66a41c66d7aa1312933cd66fa9bb0.zip
Add rgl(1df)
Diffstat (limited to 'bin/rgl')
-rwxr-xr-xbin/rgl17
1 files changed, 17 insertions, 0 deletions
diff --git a/bin/rgl b/bin/rgl
new file mode 100755
index 00000000..03f1ba71
--- /dev/null
+++ b/bin/rgl
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Read grep(1) patterns from input and search for them in the given files
+
+# Check the arguments
+if [ "$#" -eq 0 ] ; then
+ printf >&2 'rgl: Need at least one filename\n'
+ exit 2
+fi
+
+# Iterate over the patterns and search for each one; if the input is a terminal
+# include a slash prompt for the next pattern
+while {
+ [ -t 0 ] && printf /
+ read -r pat
+} ; do
+ grep -- "$pat" "$@"
+done