gpt4 book ai didi

linux -/usr/bin/find 参数列表太长

转载 作者:太空狗 更新时间:2023-10-29 12:15:01 26 4
gpt4 key购买 nike

尝试使用以下命令行搜索从 list.txt 中排除的所有文件

find . -type f -name "*.ext" $(printf "! -name %s " $(cat list.txt))

我得到以下结果

-bash: /usr/bin/find: Argument list too long

我也尝试过 xargs 但不确定我是否正确使用它。任何帮助将不胜感激。

最佳答案

我会通过管道传输到 grep:

find -type f -name '*.ext' | grep -vFf list.txt

当传递 -f 时,grep 从文件中读取搜索模式。 -v 否定搜索。通常 grep 将搜索模式视为正则表达式。如果您 -F grep 会将这些视为固定字符串。

关于linux -/usr/bin/find 参数列表太长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28727980/

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