【问题标题】:find + xargs + cat does not work with --name argumentfind + xargs + cat 不适用于 --name 参数
【发布时间】:2013-07-23 00:03:29
【问题描述】:

我正在尝试连接所有以 coref 扩展名结尾的文件。

这可行(但会添加不需要的文件):

find ../corpus/dev/txt/ | xargs cat

这不起作用。

find ../corpus/dev/txt/ -name '*.coref' | xargs cat

在第二个命令中 find 返回 1566 个结果,但 xrags cat 什么也不做。

为什么 -name 参数搞砸了?

【问题讨论】:

    标签: find cat xargs


    【解决方案1】:

    尝试像这样使用-print0

      find ../corpus/dev/txt/ -name '*.coref' -print0 | xargs -0 cat
    

    如果你发现很多文件并且 xargs 列表太长,你可以试试这个:

      find ../corpus/dev/txt/ -name '*.coref' -print0 | xargs -n1 -0 cat >> /tmp/file
    

    【讨论】:

      猜你喜欢
      • 2021-08-17
      • 1970-01-01
      • 2013-09-20
      • 1970-01-01
      • 1970-01-01
      • 2015-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多