Why does Ubuntu create a file ending in ~ for every file I create with a text editor like GNU Emacs? [duplicate]
Why does Ubuntu create a file ending in ~ for every file I create with a text editor ?
Creating a file with a text editor like GNU Emacs, say myfile, another file called myfile~ is also created. Why is this superfluous file created ? Using cat
on it displays nothing.
Thanks,
Solution 1:
Emacs' default mode is to create a backup file with a "~" suffix every time you edit and save a file. You can disable this by creating a .emacs
file in your home directory and setting an option inside it. This happens with Emacs on all platforms. Other editors may do the same under Ubuntu, but it has nothing to do with Ubuntu itself.
Solution 2:
It's a backup file that contains the file's content from before saving and will be created every time you save the file.
Solution 3:
It's emacs
(and xemacs
and jed
) -- not Ubuntu -- that creates those files. It's a copy of the previous version of the file your editing, ie. the file as it was before you made changes and used "save" to save them. I admit it's often a bother, but it's certainly useful if you've make changes you later regret.
It can be turned off manually -- and you can turn it off by default in the .emacsrc
file.
Personally I run a cron-job that removes back-ups that hasn't been accessed for more than a week.
emacs
also make files called something "#filename#" and ".#filename#". This file contained unsaved changes -- ie. things you've done since last save. The file is periodically updated as you edit a file. If emacs
(or your computer) crashes, you'll be asked to continue with the "recovered buffer" if you try to edit the file again. (These files I also periodically "cron-away".)
My advice, keep letting emacs
make back-ups... sooner or later you'll regret it if you don't.