diff options
author | stanley lieber <stanley.lieber@gmail.com> | 2011-11-21 10:39:34 -0600 |
---|---|---|
committer | stanley lieber <stanley.lieber@gmail.com> | 2011-11-21 10:39:34 -0600 |
commit | 67fe83b40f4d427d3abc5f52bc1509559ec04214 (patch) | |
tree | d7856da5612b934e0af93aaebbb754b41838242c /rc/bin/g | |
parent | 51b39ae43c55df47a8b19c9d01c84be60eda9fa0 (diff) |
add rc scripts ", "" and g from rsc
Diffstat (limited to 'rc/bin/g')
-rwxr-xr-x | rc/bin/g | 23 |
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 |