1,把redis命令按一条 一行写到txt中
[root@localhost ~]# cat test_rediscli.txt
hset Product_1 CUST_DEGREE 1
hset Product_2 CUST_DEGREE 2
hset Product_3 CUST_DEGREE 3
hset Product_4 CUST_DEGREE 4
hset Product_5 CUST_DEGREE 5
2,管道命令运行redis客户端,启用pipe模式
cat test_rediscli.txt |./redis-cli -h 192.168.137.137 -p 6379 --pipe
3,成功了
[root@localhost ~]# ./redis-cli -h 192.168.137.137 -p 6379
192.168.137.137:6379> hgetall Product_1
1) "CUST_DEGREE"
2) "1"
192.168.137.137:6379> hgetall Product_2
1) "CUST_DEGREE"
2) "2"
192.168.137.137:6379> hgetall Product_3
1) "CUST_DEGREE"
2) "3"
192.168.137.137:6379> hgetall Product_4
1) "CUST_DEGREE"
2) "4"
192.168.137.137:6379> hgetall Product_5
1) "CUST_DEGREE"
2) "5"
4,批量删除key
./redis-cli -h 192.168.137.137 -p 6379 keys "Product*" |xargs ./redis-cli -h 192.168.137.137 -p 6379 del