Created
November 17, 2011 17:17
-
-
Save dspezia/1373801 to your computer and use it in GitHub Desktop.
AWKward script to get Redis keys and values
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
redis-cli keys "*" > keys.txt | |
cat keys.txt | awk '{ printf "type %s\n", $1 }' | redis-cli > types.txt | |
paste -d'|' keys.txt types.txt | awk -F\| ' | |
$2 == "string" { printf "echo \"KEY %s %s\"\nget %s\n", $1, $2, $1 } | |
$2 == "list" || $2 == "set" { printf "echo \"KEY %s %s\"\nsort %s by nosort\n", $1, $2, $1 } | |
$2 == "hash" { printf "echo \"KEY %s %s\"\nhgetall %s\n", $1, $2, $1 } | |
$2 == "zset" { printf "echo \"KEY %s %s\"\nzrange %s 0 -1 withscores\n", $1, $2,$1 } | |
' | redis-cli |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment