Short Summary:
There are multiple options:
find . -name empty -type f -exec rm -f {} \;
will call rm
once for every file
find . -name empty -type f -exec rm -f {} +
will call rm
only as often as necessary by constructing a command line that uses the maximum length possible
find . -name empty -type f | xargs rm -f
same as above, you may (or rather will, as above - which was my approach) run into problems with filenames that contain characters that need quoting
find -name empty -type f -print0 | xargs -0 rm -f
is probably the best solution Please Upvote Dan C's comment it's his solution. It will as the earlier snippet call rm
only as often as need by constructing a command line that uses the maximum lenght possible, the -0
switch means that arguments to the rm
command will be separated by \0
so that escaping is done right in the shell.
On a side note about the comment to restrict by using -type f
you can also restrict with -size 0
(exactly 0 bytes) I can't verify if CakePHP really adheres to that convention but just about every project I know that uses placeholder files to check empty directories into the source repositories does that.
Also as Matt Simons points out adding a -v
flag might be a nice option to see some progress, however do notice that this will definitely slow down the whole process. A better approach might be to follow the process by using strace -p $pid_of_xargs
(add addtional options if you want to follow child processes, afaik that is possible)
Another note i just found in the manpage:
find -name empty -type f -delete
after all find has all of that builtin :)