utils/bash/bashrc/sources/20_fast-greps

35 lines
721 B
Plaintext
Raw Normal View History

2014-08-04 09:40:25 +00:00
#!/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
}