summaryrefslogtreecommitdiff
path: root/rc/bin/g
diff options
context:
space:
mode:
authorstanley lieber <stanley.lieber@gmail.com>2011-11-21 10:39:34 -0600
committerstanley lieber <stanley.lieber@gmail.com>2011-11-21 10:39:34 -0600
commit67fe83b40f4d427d3abc5f52bc1509559ec04214 (patch)
treed7856da5612b934e0af93aaebbb754b41838242c /rc/bin/g
parent51b39ae43c55df47a8b19c9d01c84be60eda9fa0 (diff)
add rc scripts ", "" and g from rsc
Diffstat (limited to 'rc/bin/g')
-rwxr-xr-xrc/bin/g23
1 files changed, 23 insertions, 0 deletions
diff --git a/rc/bin/g b/rc/bin/g
new file mode 100755
index 000000000..e75da7310
--- /dev/null
+++ b/rc/bin/g
@@ -0,0 +1,23 @@
+#!/bin/rc
+
+flags=()
+while(! ~ $#* 1 && ~ $1 -* && ! ~ $1 --){
+ flags=($flags $1);
+ shift
+}
+if(~ $1 --)
+ shift
+
+switch($#*){
+case 0
+ echo 'usage: g [flags] pattern [files]' >[1=2]
+ exit usage
+case 1
+ pattern=$1
+ files=(`{ls *.[bcChm] *.cc *.py *.tex *.ms *.java >[2]/dev/null})
+case *
+ pattern=$1
+ shift
+ files=($*)
+}
+grep -n $flags -- $pattern $files /dev/null