0

When getting all the keys from Redis, like this:

redis.server.com:6379> keys *
1) "z13235jxby03knne1w1gucl5"

Instead of manually copying the long key to execute get z13235jxby03knne1w1gucl5, I'd like to run something like get $(1) (pseudo code) to get the value at position 1, as output by the keys command.

Is this possible, if not, is there any workaround to not have to manually copy paste?

Note, I don't want to solve this with a script, then I prefer just copy and paste it

Max
  • 488
  • 8
  • 19

1 Answers1

0

off the top of my head, I'm not aware of a way from inside the cli.

But, Regardless of any performance implications, you can pipe the cli command lines together , but you have to do it from the shell

redis-cli --raw KEYS "*" | sed -n 1p | xargs redis-cli GET

where the 1 in :

sed -n 1p
is the line number (1-based index) inside KEYS output.

but still you need to do your validations; like making sure the index is withing the nuber of keys returned by the KEYS command all keys are of simple string type ; not sets, hash maps, etc...

Assem
  • 516
  • 3
  • 10