Amaynut
Amaynut

Reputation: 4271

redis-cli do a ttl command with a pattern

I want to display the ttl of all the keys I have in Redis at once from the redis-cli shell.

I tried things like

redis-cli keys * | xargs redis-cli TTL 

But it's not working, I keep getting the error:

(error) ERR wrong number of arguments for 'ttl' command

Upvotes: 3

Views: 1888

Answers (1)

nnog
nnog

Reputation: 1682

If you're using bash, be careful with globbing on "*". Also, xargs will need a replace-string like this:

redis-cli KEYS '*' | xargs -I{} redis-cli TTL {}

Upvotes: 3

Related Questions