find -exec always creates a file in parent directory

banderas20

Active Member
Joined
Aug 1, 2018
Messages
102
Reaction score
42
Credits
799
Hi!

I have a simple directory structure:

ParentDIR
-A
-B
-C
.....

A,B,C are subdirs of ParentDIR. All of them contain a single file.

I need to run a command on every file, but no matter what I do. The resulting file always appears always in the parent directory. And I need the commando to be executed in every subdir.

I have tried the following (with exec and execdir):

find . -type f -name foo -exec xmllint --format {} > foo_formatted \;
find . -type f -name foo -execdir xmllint --format {} > {}_formatted +


Both commands create the resulting file in ParentDIR.

¿What do I need to do to create each resulting file in its own directory?

Thanks in advance!
 


Latest posts

Top