Haui's bytes

news, diary, journal, whatever

[HowTo] Delete vim’s backup files

In general, vim’s auto backup function (:set backup) is a rather useful feature that saved me, or more precisely, some of my files several times. Nevertheless, all these files with an appended tilde, flooding your filesystem, are quite annoying. So, here’s a way to get rid of all these files in one go:

#find all backup files in your home directory
find ~ -name "*~"
#find and delete all backup files in your home directory
find ~ -name "*~" -delete
#find all backup files and delete them only if the original files exist!
find ~ -name "*~" -exec bash -c '[ -e "${1%?}" ] && rm -f -- "$1";' _ {} \;