0

I have a problem; 1) I'm using find command to find directories; 2) I need to execute another find command in previously found directories. I'want something like this find . -type d -not -name bad | xargs find {0} * Is it possible somehow to tell xargs where to put result of the previous command output {0}.

I found a solution by using -exec instead of xargs command: find . -type d -not -name bad -exec find {} -name '*' \;

But I personally more like xargs, is it possible to do that thing with xargs?

2 Answers 2

1

If I understand your requirement correctly, you might be better to do something more akin to:

find . -type d | grep -i <bad> | xargs -i find {} -type f

The pipe through grep is more personal preference - you could keep using the args to find to exclude the directories you aren't interested in. The key thing here is the -i switch to xargs and the use of {} rather than {0}.

1
  • +1 for xargs -i command {} params
    – user69817
    Jul 19, 2011 at 15:26
0

find + xargs without using -print0 can be dangerous. See why: http://en.wikipedia.org/wiki/Xargs#The_separator_problem

You may want to use GNU Parallel instead:

find . -type d | grep -i <bad> | parallel find {} -type f

Learn more: http://www.youtube.com/watch?v=OpaiGYxkSuQ

You must log in to answer this question.