【问题标题】:xargs respect wildcards in searchesxargs 在搜索中尊重通配符
【发布时间】:2012-06-19 00:51:59
【问题描述】:

我有一个名为 file1.txt 的文件:

dir1
dir2
dir3
...

我想使用 xargs 来检查文件系统中是否存在一些文件,如下所示:

 cat file1.txt | xargs -i ls  /projects/analysis7/{}/meta_bwa/hg19a/*varFilter 2>/dev/null

但 xargs 似乎永远不够聪明,无法扩展 *.即,即使文件与模式匹配(如果 * 已扩展),它也永远不会找到文件。

有什么想法吗?

【问题讨论】:

    标签: bash xargs


    【解决方案1】:

    你只需要添加sh -c:

     cat file1.txt | xargs -i sh -c 'ls  /projects/analysis7/{}/meta_bwa/hg19a/*varFilter' 2>/dev/null
    

    【讨论】:

    • 请注意,当在 file1.txt 中找到通配符时,这也有效。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-25
    • 2016-03-16
    • 2012-08-29
    • 2015-03-15
    • 2018-04-20
    相关资源
    最近更新 更多