How do I execute find with GNU xargs to traverse a set of directories?
- by wilhelmtell
$ 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.