I use Emacs and it sometimes makes backup for edited files. After a few days, I would have a lot of backup files whose name ends with a tilde.
Is there a way to find these files and delete them at once?
I tried this:
find "*" -type f -iname *~
But it doesn't work. I want the command to work recursively – something like ls -alR
.
Go to the windows explorer and search with this string, on the related folder. It will give you all the tilde files unterneath this tree. Normally you can delete them all, especially if they are older.
If a file is appended with a tilde~ , it only means that it is a backup created by a text editor or similar program; it does not suggest another program is writing to that file.
Files that suddenly appear with a tilde are usually backups of a file that was opened or still opened. For example, with a file called myfile. doc, when it is opened in Microsoft Word, the ~$myfile. doc is created. It is a temporary backup file, used to recover data if the software crashes or stops unexpectedly.
Finding files by name is probably the most common use of the find command. To find a file by its name, use the -name option followed by the name of the file you are searching for.
You need to escape from the shell. And you need to specify search path, not *
find . -type f -name '*~'
To delete the files:
find . -type f -name '*~' -exec rm -f '{}' \;
You can do something like that :
find . -type f -name '*~' -delete
If you want to delete also #*# file :
find . -type f -name '*~' -o -name '#*#' -delete
You can print all deleted files with "-print":
find . -type f -name '*~' -delete -print
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With