I want to remove keys that match "user*".
How do I do that in redis command line?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is not a feature right now to be able to do in one shot (see the comments in the
DELdocumentation). Unfortunately, you are only left with usingKEYS, looping through the results, and then usingDELto remove each one.How about using bash a bit to help?
To step through it:
echo 'KEYS user*' | redis-cli | awk '{print $1}'— get all the keys and strip out the extra text you don’t want with awk.echo DEL $key— for each one, create an echo statement to remove it.| redis-cli— take the DEL statements and pass them back into the cli.Not suggesting this is the best approach (you might have some issues if some of your usernames have spaces in them, but hopefully you get the point).