utils/bash/bashrc/sources/20_fast-greps
2014-08-04 17:40:25 +08:00

35 lines
721 B
Bash
Executable File

#!/bin/bash
function grepmysql () {
if [[ -z "$1" ]]; then
__func_head "MySQL_SERVER_NAME [WITH_OPTIONS]"
echo
else
if [[ -z "$2" ]]; then
grep -i $1 ~/.mysql_pass | awk 'BEGIN{FS=":"}{ print $2 }'
else
grep -i $1 ~/.mysql_pass | awk 'BEGIN{FS=":"}{ print $2" "$3 }'
fi
fi
}
function grepdb () {
if [[ -z "$1" ]]; then
__func_head "DB_NAME"
echo
else
grep $1 ~/.db_pass | awk 'BEGIN{FS=":"}{ print $2 }'
fi
}
function greptype() {
if [[ -z "$1" ]]; then
__func_head "TYPE GREP_ARGS"
echo
else
CMD="grep --color=auto -n --include=*.$1"
shift
$CMD $@
fi
}