The Computer Oracle

How can I use '{}' to redirect the output of a command run through find's -exec option?

--------------------------------------------------
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Dream Voyager Looping

--

Chapters
00:00 Question
00:56 Accepted answer (Score 40)
01:15 Answer 2 (Score 5)
01:40 Thank you

--

Full question
https://superuser.com/questions/231495/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #find #redirection

#avk47



ACCEPTED ANSWER

Score 40


You can do the redirection like this:

find /var/svn/* \( ! -name dir -prune \) -type d -exec sh -c 'svnadmin dump {} > {}.svn' \;

and the correct substitution will be done.




ANSWER 2

Score 5


No, however you can write a simple bash script to do that then call it from find.
Example (/tmp/dump.sh):

#!/bin/sh
svn admin dump "$1" > "$1".svn

then:

find /var/svn/* \( ! -name dir -prune \) -type d -exec sh /tmp/dump.sh '{}' \;