Created a shell script that deletes keys that matches a pattern using the following script:
host=${1:-}
port=${2:-6379}
database=${3:-0}
pattern=${4:-"Test"}
cursor=-1
keys=""
echo "Starting to delete"
while [ $cursor -ne 0 ]; do
  if [ $cursor -eq -1 ]
  then
    cursor=0
  fi
  reply=`redis-cli -h $host -p $port SCAN $cursor MATCH $pattern`
  cursor=`expr "$reply" : '\([0-9]*[0-9 ]\)'`
  keys=${reply##[0-9]*[0-9 ]}
  echo "$keys"
  redis-cli -h $host -p $port DEL $keys
done
This is working fine for keys that doesn't have hex in keys. But when keys with hex characters involved, encountered an unknown operand error message. Sample key:
\xac\xed\x00\x05t\x00\x15test
Need suggestions on how to escape these characters.
The same problem here: https://stackoverflow.com/questions/46854691/how-to-delete-redis-keys-with-special-characters
