redis 模糊删除脚本
#!/bin/bash #修改成自己的ip、密码、库名以及所要匹配的字符串 db_ip=192.168.1.100 db_port=6379 password=963852741 dbnum=0 str="niubi:*" cursor=0 cnt=1000 new_cursor=0 redis-cli -h $db_ip -p $db_port -a $password -n $dbnum scan $cursor match $str count $cnt > scan_tmp_result new_cursor=`sed -n '1p' scan_tmp_result` sed -n '2,$p' scan_tmp_result > scan_result sed -n '1,$p' scan_result|xargs redis-cli -h $db_ip -p $db_port -a $password -n $dbnum del >/dev/null while [ $cursor -ne $new_cursor ] do redis-cli -h $db_ip -p $db_port -a $password -n $dbnum scan $new_cursor match $str count $cnt > scan_tmp_result new_cursor=`sed -n '1p' scan_tmp_result` sed -n '2,$p' scan_tmp_result > scan_result sed -n '1,$p' scan_result|xargs redis-cli -h $db_ip -p $db_port -a $password -n $dbnum del >/dev/null done
螃蟹在剥我的壳,笔记本在写我,漫天的我落在枫叶上雪花上,而你在想我。
--章怀柔