Skip to content

Instantly share code, notes, and snippets.

@saetia
Last active April 15, 2016 20:32
Show Gist options
  • Save saetia/6356135 to your computer and use it in GitHub Desktop.
Save saetia/6356135 to your computer and use it in GitHub Desktop.
findin
#!/bin/bash
if [ $# -eq 0 ]; then
echo -e "Usage: $0 site.com \033[32m'alert'\033[0m js"
exit
fi
if [ ! -d /var/www/${1}/public ]; then
echo -e "\033[31mfailed:\033[0m ${1} does not exist"
exit
fi
FILETYPE=""
FILEEXT="all"
if [ $# -eq 3 ]; then
FILETYPE="-iname *.${3}"
FILEEXT=".${3}"
fi
echo -e "searching for \033[32m'${2}'\033[0m on \033[32m${1}\033[0m in \033[32m$FILEEXT\033[0m files"
find /var/www/${1}/public $FILETYPE -type f -print0 | xargs -0 fgrep --color=always "${2}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment