Easy find
I found myself typing find . -name "*.java" | xargs -iHn "something" so often I decided to make it into a bash script and put it in a new ~/Dropbox/bin folder so that I never have to do it again. Worse I never use the print0 option which let's you search files that have spaces in the filename, as it's too hard to remember. So, here's the script.
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
#!/bin/bash | |
# A simple script to recursively search files | |
if [ "$#" -ne 3 ]; then | |
echo "efind (easy find) usage: [path] [file pattern] [regex]" | |
echo 'efind ../c "*.c" "string"' | |
exit 1 | |
fi | |
find "$1" -name "$2" -type f -print0 | xargs -0 egrep -iHn "$3" | |