Created
February 1, 2011 00:40
-
-
Save kristjan/805168 to your computer and use it in GitHub Desktop.
A little something to prevent hanging greps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
query = $*.shift | |
if $*.empty? && $stdin.tty? | |
puts "You haven't given grep anything" | |
else | |
cmd = %(grep "#{query}" #{$*.join(' ')}) | |
puts `#{cmd}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! Probably more portable in bash, I think: