by mmorey · 13y ago · 0 comments
find . -name "*.swp"
You can find and remove them with: find . -name "*.swp" -exec rm -f \{\} \;find . -name "*.swp" | xargs rm
I believe find -exec forks and execs once for every file found, xargs may only fork and exec once, provided that all of the files find finds fit in a single command line. Hopefully not an issue in this case, but it can greatly speed up a deletion when you have a lot of files to find and delete.
[EDIT] Doesn't properly handle spaces in filenames, see the comments below for other slick solutions.
You need to add -print0 to find, and -0 to xargs to make it work properly: find . -name "*.swp" -print0 | xargs -0 rm
But better would be to use -delete as I wrote above.