-
-
Save hidsh/5353679 to your computer and use it in GitHub Desktop.
Yet Another Alternative to 'grep find' using mdfind(a.k.a. Spotlight) on Mac OS X
This file contains hidden or 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
#!/bin/sh | |
# | |
# g - Yet Another Alternative to 'grep find' using mdfind(a.k.a. Spotlight) on Mac OS X | |
# | |
# usage: | |
# $g hoge | |
# $g hoge dir | |
USAGE="usage:\n\ | |
\$g hoge\n\ | |
\$g hoge dir" | |
if [ $# -lt 1 ] || [ $# -gt 2 ]; then | |
echo $USAGE | |
exit 0 | |
fi | |
WORD=$1 | |
if [ $# -lt 2 ]; then | |
DIR="." | |
else | |
DIR=$2 | |
fi | |
mdfind -0 -onlyin $DIR $WORD | xargs -0 grep -Hin $WORD | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment