问题
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