redis获取所有的key和value shell脚本

#!/bin/bash
# fffmo.com redis维护

log="/home/admin/redis-3.1.14/src/redis-cli -a adeafgsd231234 -h 10.0.53.126  -p 6379"
#获取db_num
db_num=$($log info Keyspace |grep db |wc -l )
db_save=$($log info Keyspace |grep db   |awk -F"[b|:]" '{print $2}' )
echo "the db have at least values is $db_save ..."
echo "\n"
echo "================Begin================================="

fffmo_db() {
for i  in $(echo "keys *" | $log -n $1| awk -F"\"" '{print $1}') ;
    do
        value=$(echo "get $i" | $log -n $1 );
        echo -e  "key:$i\t values:$value" ;
done
}

for fix in $($log info Keyspace |grep db   |awk -F"[b|:]" '{print $2}' ); do 
    echo -e "\n"
    echo -e "the key-value of $fix is ..."
    echo -e "==============================================="
    fffmo_db $fix 
    echo 
done
赞(3) 打赏
特别声明:除特殊标注,本站文章均为原创,遵循CC BY-NC 3.0,转载请注明出处。三伏磨 » redis获取所有的key和value shell脚本

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏