Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k
Tweeted twitter.com/#!/StackUnix/status/306803039614939136
Source Link
turtle
  • 2.8k
  • 7
  • 22
  • 17

Remove all Vim undo files in all but one directory

I just realized that I have tons of Vim undo (.un~) files sprinkled around my file system. I'd like to delete all of these files except in one directory—~/.tmp. My first problem is that I can't seem to find a Unix command to delete these things. For example, I have a file name that looks like this:

.myfile.txt.un~

I've tried, rm -f *.un, rm -f *.un\~, rm -f *.un*, etc. and I can't seem to find any command that can delete these files. How can I delete these files?

Secondly, I'd like to write a command with find that can visit all my directories and delete these files, with the exception of the ~/.tmp directory. I'm quite afraid of executing this command incase it's wrong. Can anyone help be construct a find command to do this? Thanks in advance for the help!