【问题标题】:redis-cli do a ttl command with a patternredis-cli 使用模式执行 ttl 命令
【发布时间】:2016-04-12 04:08:10
【问题描述】:

我想从 redis-cli shell 一次显示我在 Redis 中所有键的 ttl。

我尝试过类似的东西

redis-cli keys * | xargs redis-cli TTL 

但它不起作用,我一直收到错误:

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

【问题讨论】:

    标签: linux shell redis redis-cli nosql


    【解决方案1】:

    如果您使用的是 bash,请小心使用“*”上的通配符。此外,xargs 将需要这样的替换字符串:

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

    【讨论】:

    • 我刚刚尝试过,但出现错误:xargs: TTL: No such file or directory
    • 但是我在我的鱼壳中尝试了这个命令。现在我在 bash shell 中试过了。
    猜你喜欢
    • 2012-06-05
    • 2021-10-08
    • 2017-05-11
    • 2018-03-10
    • 2017-06-23
    • 1970-01-01
    • 1970-01-01
    • 2017-09-16
    • 1970-01-01
    相关资源
    最近更新 更多