-
Notifications
You must be signed in to change notification settings - Fork 38
/
search
executable file
·21 lines (21 loc) · 1.08 KB
/
search
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
## THIS IS A GREAT RETRO ENGINEERING AND CODE SNIFFING TOOLS
clear
[[ ! -s ~/.local/bin/${ME} ]] && cp ${MY_PATH}/${ME} ~/.local/bin/ && echo "Auto Install into ~/.local/bin/${ME}"
echo "------------------------------------------------------------------------------"
if [ "$1" == "" ]; then
echo " Nothing to search for!"
else
echo " Searching for "$1" recursively. Please Wait..."
echo "------------------------------------------------------------------------------"
grep -h -r --exclude-dir='.git*' --exclude='twsector.html' --exclude='twuplanet.html' --exclude='twdefault.html' -H --colour=always "$1" ./
fi
echo "------------------------------------------------------------------------------"
if [ "$2" != "" ]; then
echo " To replace \"$1\" whith \"$2\", please run"
echo " grep -rl --exclude-dir='.git*' --exclude='twsector.html' --exclude='twuplanet.html' --exclude='twdefault.html' '$1' ./ | xargs sed -i 's~$1~$2~g'"
fi
exit 0