Skip to main content
* doesn't match dot files
Source Link
Gilles 'SO- stop being evil'
  • 866.5k
  • 205
  • 1.8k
  • 2.3k

Most of those rmThese commands should've workeddidn't work because wildcard patterns omit dot files (notfiles whose name begins with the character .) unless the dot appears explicitly in the pattern. So *.unun~ matches yourfile.txt.un~ but not .myfile.txt.un~, since that doesn't matchwhereas .*.un~), so if they didn't you might have some other problem does match .myfile.txt.un~. In any case, you

You should be able to use find(1) for this (find wildcard matching doesn't treat dot files specially):

find / -name "*.un~" -not -path "~/.tmp/*" -delete 

That tells find to search / for all files matching *.un~ that aren't in ~/.tmp and delete them. If you take off -delete it will just output a list, so you can check and make sure it's not going to delete the wrong things. You also might want to throw -mount in there to stop it from searching other filesystems you have mounted

Most of those rm commands should've worked (not *.un, since that doesn't match *.un~), so if they didn't you might have some other problem. In any case, you should be able to use find(1) for this:

find / -name "*.un~" -not -path "~/.tmp/*" -delete 

That tells find to search / for all files matching *.un~ that aren't in ~/.tmp and delete them. If you take off -delete it will just output a list, so you can check and make sure it's not going to delete the wrong things. You also might want to throw -mount in there to stop it from searching other filesystems you have mounted

These commands didn't work because wildcard patterns omit dot files (files whose name begins with the character .) unless the dot appears explicitly in the pattern. So *.un~ matches yourfile.txt.un~ but not .myfile.txt.un~, whereas .*.un~ does match .myfile.txt.un~.

You should be able to use find(1) for this (find wildcard matching doesn't treat dot files specially):

find / -name "*.un~" -not -path "~/.tmp/*" -delete 

That tells find to search / for all files matching *.un~ that aren't in ~/.tmp and delete them. If you take off -delete it will just output a list, so you can check and make sure it's not going to delete the wrong things. You also might want to throw -mount in there to stop it from searching other filesystems you have mounted

Source Link
Michael Mrozek
  • 95.8k
  • 40
  • 245
  • 236

Most of those rm commands should've worked (not *.un, since that doesn't match *.un~), so if they didn't you might have some other problem. In any case, you should be able to use find(1) for this:

find / -name "*.un~" -not -path "~/.tmp/*" -delete 

That tells find to search / for all files matching *.un~ that aren't in ~/.tmp and delete them. If you take off -delete it will just output a list, so you can check and make sure it's not going to delete the wrong things. You also might want to throw -mount in there to stop it from searching other filesystems you have mounted