Created
September 14, 2012 21:13
-
-
Save emilyst/3724875 to your computer and use it in GitHub Desktop.
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
# Find a file | |
function ff() { find . -type f -iname '*'$*'*' -ls ; } | |
# Find a file with pattern $1 in name and execute $2 on it | |
function fe() { find . -type f -iname '*'${1:-}'*' -exec ${2:-file} {} \; ; } | |
# Find a pattern in a set of files and highlight them | |
# (needs a recent version of egrep) | |
function fs() | |
{ | |
OPTIND=1 | |
local case="" | |
local usage="fs: find string in files. | |
Usage: fs [-i] \"pattern\" [\"filename pattern\"] " | |
while getopts :it opt | |
do | |
case "$opt" in | |
i) case="-i " ;; | |
*) echo "$usage"; return;; | |
esac | |
done | |
shift $(( $OPTIND - 1 )) | |
if [ "$#" -lt 1 ]; then | |
echo "$usage" | |
return; | |
fi | |
find . -type f -name "${2:-*}" -print0 | \ | |
xargs -0 zegrep --color=always -sn ${case} "$1" 2>&- | more | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment