How do I execute find with GNU xargs to traverse a set of directories?
Posted
by wilhelmtell
on Super User
See other posts from Super User
or by wilhelmtell
Published on 2010-02-07T19:49:41Z
Indexed on
2010/03/12
22:07 UTC
Read the original article
Hit count: 341
xargs
$ echo {a,b,c}.h d e.h |xargs -IA find A -name '*.h'
find: `a.h b.h c.h d e.h': No such file or directory
$ echo -e a.h\\nb.h c.h d e.h |xargs -IA find A -name '*.h'
a.h
find: `b.h c.h d e.h': No such file or directory
The problem is that -I
implies xargs will assume arguments are delimited by newline. I'm not sure why that is. I reckon I can solve this problem with sed, but I wonder if there's an xargs trick or idiom I'm not familiar with that people use to solve this.
I'm looking for a solution that will also work on OS X. On OS X the xargs -J switch seems to work fine. The manpage claims this switch will just control where the arguments are placed for the executable -- which is exactly what I want.
© Super User or respective owner