Skip to content

Instantly share code, notes, and snippets.

@sebolio
Last active August 8, 2016 16:42
Show Gist options
  • Save sebolio/cdcae475a433244fc876 to your computer and use it in GitHub Desktop.
Save sebolio/cdcae475a433244fc876 to your computer and use it in GitHub Desktop.
Búsqueda texto en archivos con find
#busca solo en archivos (cambiar type en caso de querer otra cos)
#uso: sh buscar.sh <busqueda> <extension>
#remoto: bash <(curl -s URL.DEL.GIST)
buscar() {
echo "Buscando '$bus' en extension '$ext'"
find . -type f -exec sh -c "echo {}|grep -q '\.$ext' && echo '\033[0;31m Analizando \033[0;32m {} \033[0m:' && (cat {}|grep \"$bus\") " \;
}
ext=$2
bus=$1
if [ -z $bus ]; then echo -n "Buscar: "; read bus; fi
[[ ${#bus} -gt 2 ]] && buscar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment