【问题标题】:list all sub directories containing certain file, then copy those directories somewhere列出包含特定文件的所有子目录,然后将这些目录复制到某处
【发布时间】:2017-04-13 17:34:41
【问题描述】:

从我的当前目录中,我有子目录。我想列出一个包含以449.ss 结尾的文件的子目录。

我可以这样做:

find . -iname "*-449.ss" | sed -e 's!/[^/]*$!!' -e 's!^\./!!' | sort -u

但是我想将所有这些目录复制到一个新目录correct。我试过了

$ find . -iname "*-449.ss" | sed -e 's!/[^/]*$!!' -e 's!^\./!!' | sort -u | xargs -0 -I{} cp -r {} correct/
cp: cannot stat `polyid4ssnps105\npolyid4ssnps106\npolyid4ssnps107\n': File name too long

我尝试传递给xargs。但是,这已将列表视为单个字符串。

我哪里出错了?

谢谢。

【问题讨论】:

    标签: bash directory copy find


    【解决方案1】:
    xargs -l ...
    

    同时删除参数-0

    人 xargs:

       -l[max-lines], --max-lines[=max-lines]
              Synonym for the -L option.  Unlike -L, the max-lines argument is
              optional.  If max-lines is not specified, it  defaults  to  one.
              The  -l  option is deprecated since the POSIX standard specifies
              -L instead.
    

    【讨论】:

      猜你喜欢
      • 2020-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-11
      • 2011-08-05
      相关资源
      最近更新 更多