Skip to content

Instantly share code, notes, and snippets.

@ckng
Created December 3, 2014 04:45
Show Gist options
  • Save ckng/6a467d54ef5a80887ee0 to your computer and use it in GitHub Desktop.
Save ckng/6a467d54ef5a80887ee0 to your computer and use it in GitHub Desktop.
Redis: Bulk delete key
#!/bin/bash
if [[ -z $1 ]]
then
echo "Usage: $0 <key>, key: key to delete, e.g. \"mykey*\""
exit 1;
fi
# does not check if key exists
# if key does not exists, you likely get "ERR wrong number of arguments for 'del' command"
echo "Redis: bulk removing key \"$1\""
/usr/bin/redis-cli KEYS "$1" | xargs /usr/bin/redis-cli DEL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment