Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

As in

find -L /etc/ssl/certs/ -type l -exec rm {} +

So it finds all broken symlinks and deletes them. But how exactly do I interpret the {} + part?

share|improve this question
    
I didn't know about the "+" variant. Thanks for pointing it out! –  wfaulk Oct 9 '09 at 15:33
add comment

2 Answers

up vote 4 down vote accepted

The {} bit is the placeholder for the exec command. Whatever files are found by find are inserted in place of the brackets. The + means to build up a long list of the found files and call the exec on all of them at once instead of one at a time, like the more traditional -exec {} \; variant.

share|improve this answer
add comment

From man find:

   -exec command {} +
   This variant of the -exec option runs the specified  command  on
   the  selected  files, but the command line is built by appending
   each selected file name at the end; the total number of  invoca-
   tions  of  the  command  will  be  much  less than the number of
   matched files.  The command line is built in much the  same  way
   that  xargs builds its command lines.  Only one instance of '{}'
   is allowed within the command.  The command is executed  in  the
   starting directory.

So it will call the command:

rm [filename1] [filename2] [...] [lastfilename]

If there are more files than can fit in the argument list rm will be called more than once. (This is what xargs does.)

Without the {} + it would just call rm a bunch of times with no arguments.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.