Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove all files ending with ~ made by Emacs

Tags:

emacs

backup

Whenever I edit files on emacs, it seems a temporary file is created with the same name with ~ appended to it. Does anyone know an quick/easy way to delete all of these files in the working directory?

like image 224
jhchen Avatar asked Apr 21 '10 04:04

jhchen


People also ask

How do I remove all file extensions?

Using rm Command To remove a file with a particular extension, use the command 'rm'. This command is very easy to use, and its syntax is something like this. In the appropriate command, 'filename1', 'filename2', etc., refer to the names, plus their full paths.

How do I delete Emacs files?

You can delete these from emacs quite conveniently. Open up dired (C-x d) and press # to select all of them in the directory. Then x for delete.

How do I delete all files by name on Mac?

Type "-name" followed by a space and then the file name pattern you would like to search for in quotes. To have the command delete files, finish off the command with the "-delete" flag.


1 Answers

While all the others answers here correctly explain how to remove the files, you ought to understand what's going on. Those files ending in ~ are backup files, automatically created by Emacs. They can be useful sometimes. If you're annoyed by the files and want to delete them every time, then you either

(1). prevent the creation of backup files:

(setq make-backup-files nil) 

or

(2). Have it save the backup files in some other directory, where they won't bother you unless you go looking for them. I have the following in my .emacs:

(setq backup-directory-alist '(("." . "~/.emacs.d/backup"))   backup-by-copying t    ; Don't delink hardlinks   version-control t      ; Use version numbers on backups   delete-old-versions t  ; Automatically delete excess backups   kept-new-versions 20   ; how many of the newest versions to keep   kept-old-versions 5    ; and how many of the old   ) 

(Only the first line is crucial.) To see documentation about backup-directory-alist, type C-h v backup-directory-alist.

like image 198
ShreevatsaR Avatar answered Oct 05 '22 23:10

ShreevatsaR