Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@justinhj
Created June 29, 2014 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinhj/f4cca62abf809eb49622 to your computer and use it in GitHub Desktop.
Save justinhj/f4cca62abf809eb49622 to your computer and use it in GitHub Desktop.
A bash script to easily search files for a regular expression
#!/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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment