#!/bin/bash func() { echo "Usage:" echo " bigkeys [options]" echo "" echo "General Options:" echo " -H Show help." echo " -h Server hostname (default: 127.0.0.1)" echo " -p Server port (default: 6379)" echo " -a Password to use when connecting to the server." } func_getRedisBigkeys(){ #redis_path=`ps -ef |grep -i redis-server|grep -v grep |awk '{print $8}'` #cli=`$redis_path|sed -e "s/redis-server/redis-cli/g"` if [ -z $3 ]; then redis-cli --bigkeys -h $1 -p $2 else redis-cli --bigkeys -h $1 -p $2 -a $3 fi } while getopts ":HBh:p:a:" opt; do case ${opt} in H ) func ;; h ) host=$OPTARG ;; p ) port=$OPTARG ;; a ) password=$OPTARG ;; B ) echo "******get redis bigkeys******" #func_getRedis ;; # b ) # base_path=$OPTARG # ;; ? ) func ;; esac done shift $(($OPTIND - 1)) if [ -z $host ]; then host='127.0.0.1' fi if [ -z $port ]; then port=6379 fi #if [ -z $base_path ]; then # echo "请输入redis主目录" # exit 1 #fi func_getRedisBigkeys $host $port $password