Last active
May 22, 2020 19:41
-
-
Save lucassabreu/63217236273a8308dd365044343c8669 to your computer and use it in GitHub Desktop.
A redis-cli helper to delete keys by a pattern (using docker run)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$1" -eq '--help' ] && { | |
echo "usage: redis-cli-del-keys.sh <pattern e.g. user:*> -h <hostname> -n <db-number> [<other connection parameters|...>]" | |
exit 1 | |
} | |
docker run --rm redis redis-cli ${@:2} --scan --pattern $1 | sort | uniq | sed 's|\s\+| |g' | xargs docker run --rm redis redis-cli ${@:2} del |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment