Expanding globs in xargs

Posted by Craig on Super User See other posts from Super User or by Craig
Published on 2011-06-29T23:29:54Z Indexed on 2011/06/30 0:24 UTC
Read the original article Hit count: 519

Filed under:
|
|
|
|

I have a directory like this

mkdir test
cd test
touch file{0,1}.txt otherfile{0,1}.txt stuff{0,1}.txt

I want to run some command such as ls on certain types of files in the directory and have the * (glob) expand to all possibilities for the filename.

echo 'file otherfile' | tr ' ' '\n' | xargs -I % ls %*.txt

This command does not expand the glob and tries to look for the literal 'file*.txt'

How do I write a similar command that expands the globs? (I want to use xargs so the command can be run in parallel)

© Super User or respective owner

Related posts about linux

Related posts about osx