Skip to content

Instantly share code, notes, and snippets.

@MattSurabian
Last active November 14, 2018 17:52
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save MattSurabian/9534815 to your computer and use it in GitHub Desktop.
Save MattSurabian/9534815 to your computer and use it in GitHub Desktop.
One liner for deleting based on a pattern in redis. KEYS supports wildcards, delete doesn't. No worries xargs to the rescue. You might not need HOST, or PORT depending on your setup. You might need to sudo BOTH commands depending on your setup.
redis-cli -h <HOST> -p <PORT> KEYS "<PATTERN>" | xargs -i% redis-cli -h <HOST> -p <PORT> DEL %
@yellow1912
Copy link

this has issue with keys containing special characters, you need to wrap each key in single quote i think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment