Techblog Index

Quick Tip: Seeking and destroying the swapfiles leftovers

Once again with my VIM swapfiles problems, I’ve left too much of them around my app dirs on my pre-screen era. Every power-down or connection loss was the birth of a new swap. Well, they all appeared when I had to sync with the production server.

VIM creates the swapfiles with extensions beginning with .sw and they are preceded by a dot (.) to become a hidden file at most *NIX filesystems. To wipe’em out, our friend find proves being again a beautiful tool.

This one is easy, just run the following code on the messy directory:

find -name .*.sw* -exec rm -i {} \;

And it’s done!

NOTE: MAKE SURE YOU DON’T HAVE ANY FILE THAT MATCHES THE .*.sw* EXTENSION THAT IS NOT A SWAPFILE.

NOTE: The -i flag under the rm command enters interactive mode so you can confirm before deleting anything.

 
 

Leave a Reply