Skip to content

Instantly share code, notes, and snippets.

@dspezia
Created November 17, 2011 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dspezia/1373801 to your computer and use it in GitHub Desktop.
Save dspezia/1373801 to your computer and use it in GitHub Desktop.
AWKward script to get Redis keys and values
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