gpt4 book ai didi

bash - 删除Redis中的很多键

转载 作者:可可西里 更新时间:2023-11-01 11:05:17 27 4
gpt4 key购买 nike

尝试做类似的事情:

# redis-cli keys "resque:lock:*" |xargs -0 redis-cli del
xargs: argument line too long

解决此问题的最佳方法是什么?

最佳答案

去掉 -0。我不熟悉 redis,但据我所知,redis-cli keys 不使用 NUL 分隔符。

它没有它的原因是因为它处理引号的方式。来自 man xargs:

xargs reads items from the standard input, delimited by blanks (which can be protected with double or single quotes or a backslash) or newlines, and executes the command (default is /bin/echo) one or more times with any initial-arguments followed by items read from standard input. Blank lines on the standard input are ignored.

试试 xargs -d '\n'。这将禁用 xarg 的“智能”引号处理并告诉它逐行读取参数。

关于bash - 删除Redis中的很多键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13596371/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com