Skip to content

Instantly share code, notes, and snippets.

@DannyBen
Created April 17, 2015 12:26
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 DannyBen/4adadd0f573ec312e46e to your computer and use it in GitHub Desktop.
Save DannyBen/4adadd0f573ec312e46e to your computer and use it in GitHub Desktop.
Find files and content in files
if [ $# -lt 1 ]; then
echo "
ff - Find files and content in files
Find content in a file:
usage : ff [-t] EXTENSION SEARCH
example : ff php logdir
-t : omit text (show filenames only)
Find a file:
usage : ff PATTERN
example : ff *.css
"
exit 1
fi
if [ $# == 1 ]; then
find . -name "$1"
elif [ $1 == "-t" ]; then
grep --color=always --include=*.$2 -rnwl . -e "$3" | less -rF
else
grep --color=always --include=*.$1 -rnw . -e "$2" | less -rF
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment