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?
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?
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.
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.