xargs respect wildcards in searches

点点圈 提交于 2019-12-01 06:25:35

问题


I have a file called file1.txt:

dir1
dir2
dir3
...

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

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).

Any ideas?


回答1:


You just need to add sh -c:

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


来源:https://stackoverflow.com/questions/11087407/xargs-respect-wildcards-in-searches

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!