Home » Questions » Computers [ Ask a new question ]

How do I execute find with GNU xargs to traverse a set of directories?

How do I execute find with GNU xargs to traverse a set of directories?

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.

Asked by: Guest | Views: 285
Total answers/comments: 1
bert [Entry]

"did you try the -d option to xargs?

justin@eee:~$ echo {a,b,c}.h d e.h |xargs -d ' ' -n1 -IA echo foo A
foo a.h
foo b.h
foo c.h
foo d
foo e.h

or even simpler,

justin@eee:~$ for x in $(echo {a,b,c}.h d e.h);do echo foo $x;done
foo a.h
foo b.h
foo c.h
foo d
foo e.h"