xargs在搜索中尊重通配符 [英] xargs respect wildcards in searches

查看:60
本文介绍了xargs在搜索中尊重通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a file called file1.txt:

dir1
dir2
dir3
...

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

I wanted to use xargs to check if some files exist farther into the file system like this:

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

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

But xargs never seems smart enough to expand the *. ie, it never finds the files even when they would match the pattern (if the * was expanded).

有什么想法吗?

推荐答案

您只需要添加 sh -c :

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

这篇关于xargs在搜索中尊重通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆