I use the following line to find all sub-directories of the PWD and run svnadmin verify
on each directory (I already know that they're Subversion repositories)
find ./* -maxdepth 0 -exec svnadmin verify {} \;
This works well, other than the fact that the output looks like this:
* Verifying repository metadata ...
* Verifying metadata at revision 1 ...
* Verifying metadata at revision 2 ...
* Verifying metadata at revision 4 ...
* Verifying metadata at revision 5 ...
* Verifying metadata at revision 6 ...
* Verifying metadata at revision 9 ...
* Verifying metadata at revision 10 ...
* Verifying metadata at revision 12 ...
* Verifying metadata at revision 14 ...
* Verifying metadata at revision 15 ...
* Verifying metadata at revision 18 ...
* Verifying metadata at revision 20 ...
* Verifying metadata at revision 22 ...
* Verified revision 0.
* Verified revision 1.
* Verified revision 2.
* Verified revision 3.
* Verified revision 4.
* Verified revision 5.
* Verified revision 6.
* Verified revision 7.
* Verified revision 8.
* Verified revision 9.
* Verified revision 10.
* Verified revision 11.
* Verified revision 12.
* Verified revision 13.
* Verified revision 14.
* Verified revision 15.
* Verified revision 16.
* Verified revision 17.
* Verified revision 18.
* Verified revision 19.
* Verified revision 20.
* Verified revision 21.
* Verified revision 22.
* Verified revision 23.
* Verified revision 0.
* Verifying repository metadata ...
* Verifying metadata at revision 4 ...
* Verifying metadata at revision 5 ...
* Verifying metadata at revision 6 ...
* Verifying metadata at revision 7 ...
* Verifying metadata at revision 9 ...
* Verified revision 0.
* Verified revision 1.
* Verified revision 2.
* Verified revision 3.
* Verified revision 4.
* Verified revision 5.
* Verified revision 6.
* Verified revision 7.
* Verified revision 8.
* Verified revision 9.
I'd really like find
to print the filename before executing the svnadmin verify
command, to make logging easier.
I've tried to squeeze a little ls
in there but bodged it up, how should I do this (preferably simply)?
simply add a
-printf
option beforeIf you don't want to recurse, there's no point in using
find
. It is far simpler to do it in the shell directly:The
for d in */
will find all directories (the*/
ensures only directories and no files are found); theecho "$d"
will print the directory's name; thesvnadmin verify "$d"
will check the directory.This can be run either directly from the command line or from within a script with no change in format.
I have added
-type d
if it is only directories.Try this:
If you just want directories(Thanks to @kos note):
. -maxdepth 1
instead of./*
, you need only the first level in the folder structure-type d
, you need only folders! -name "."
, you don't need.
-exec
to start a shellsh -c
to start commands inside the shellYour command
or shorter
-prune
if the file is a directory, do not descend into itYour command
find
has option flags for printing, which are already mentioned in other answers. If we look at the problem form the perspective of executing multiple commands for the same currently processed file,find
allows using multiple-exec
statements. This means we could opt for using:Again, note that this approach is applicable to not just printing with
echo
,printf
, or other utilities, but also other commands.This will print the name and contents of files-only recursively..
Best use find with XARGS, as it has verbose option exactly for this:
So in your example:
It may be useful to pipe the
find
output toread
loop:It allows you to execute more complicated, compound command sequence with filenames returned by
find
, like in this fancyls
example: