3 ms·
I don’t have access to a Mac but the command should be faster if you change the semi-colon to a plus-sign: find $DIR -type f -name .DS_Store -exec rm {} +
by Anthony-G 6y ago
I don’t have access to a Mac but the command should be faster if you change
the semi-colon to a plus-sign:
find $DIR -type f -name .DS_Store -exec rm {} +
Completing the `-exec` predicate with the plus-sign results in only one fork-and-exec call to the `rm` command (as long as the number of arguments doesn’t exceed the system’s `ARG_MAX` limit), similar to how the `xargs` utility aggregates arguments into sets.
This feature has been in POSIX for many years so I’m guessing it should be
available with the Mac OS X version. If you install GNU find, it also includes a `-delete` action so there’s no need to even call an external command to delete files.
- jjjbokma 6y agoeven better: find has a -delete: find $DIR -type f -name .DS_Store -delete +