Last active
April 15, 2016 20:32
-
-
Save saetia/6356135 to your computer and use it in GitHub Desktop.
findin
This file contains hidden or 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
#!/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