Rob Current’s answer is certainly helpful and works.
A further example can be found via man find on macOS for deleting all broken symlinks in a given directory.
Say you have a directory /usr/ports/packages containing broken symlinks to other files or directories that have either moved or been deleted, the following command will remove all symlinks for which the previously linked file location no longer exists.
EXAMPLES
The following examples are shown as given to the shell:
...
find -L /usr/ports/packages -type l -exec rm -- {} +
Delete all broken symbolic links in /usr/ports/packages.
...
BSD September 28, 2011 BSD
The -L switch (as per man find) causes the file information and file type returned for each symbolic link to be those of the file referenced by the link, not the link itself. If, however, the referenced file does not
exist, the file information and type will be for the link itself.
The -type l switch limits the files found to those which are symbolic links.
What follows the -exec switch is the command to execute for matching files.
The -- switch causes rm, which uses getopt(3) to parse its arguments, to stop processing flag options afterwards.
As explained by man find, the syntax exec utility [argument ...] {} + has the same effect as -exec, except that ``{}'' is replaced with as many pathnames as possible for each invocation of the utility. This behaviour is similar to that of xargs(1).
Hope that’s helpful.