The following operations need to be run on a unix system. You can use Bash on Windows is you have a Windows OS.
$ sudo apt-get install redis-toolsCreate the following bash file
#!/bin/bash
redis-cli -h 127.0.0.1 -p 6379 keys "test:*" > keys
cat keys | xargs -n 1 -L 1 redis-cli -h 127.0.0.1 -p 6379 ttl > ttl
paste -d " " keys ttl | grep .*-1$ | cut -d " " -f 1 > without_ttl
cat without_ttl | awk '{print "redis-cli -h 127.0.0.1 -p 6379 del "$1}' > redis.sh
- You can change
127.0.0.1with the desired server IP Address - You can change
6379with the desired server Port number - You can change
test:*with the desired key format to scan
$ chmod +x your_file.sh- Execute your script file
- This will create
keys,ttl,without_ttlandredis.shfiles
- You can review the files before continuing
- Execute the script
redis.sh