-2

I created a file called file2.txt in Linux, opened it in text editor and saved it. When I closed the text editor I see two files file2.txt and file2.txt~

I guess file2.txt~ is temporary file created when I am editing the file2.txt but it should get removed when I finished saving and closed text editor.

Rahul Kumar
  • 2,184
  • 3
  • 24
  • 46
  • No, the Emacs backup files are left around as a primitive undo facility. You can disable it if you like; but this is rather basic knowledge, and not programming-related. – tripleee Jan 02 '16 at 16:01
  • Take a look at your text editor settings. It will have some kind of checkbox saying about temporary files. You can uncheck it and the editor won't have any temporary files. In fact these are not temporary files but backup copies. – Sergey Kanaev Jan 02 '16 at 16:02
  • @tripleee I did not see any hints to emacs in the question – Sergey Kanaev Jan 02 '16 at 16:02
  • Pure conjecture. If you know other editors which work this way, feel free to suggest. – tripleee Jan 02 '16 at 16:04

2 Answers2

1

These files are most likely your text editor's auto backup, or maybe some other piece of software that manipulates original files (without ~ postfix). Check your software settings for auto save and auto backup. I'd strongly suggest not to disable auto backup, but rather customize a path where your editor saves them. For example, you can easily do that in Emacs text editor (see this discussion and wiki)

In case you still want to get rid of these files, you can always do that in your command line as follows:

rm *~

You can also remove these files recursively, i.e. not only in the current directory, but also in subdirs:

find . -type f -name "*~" -exec rm {} +
vrs
  • 1,922
  • 16
  • 23
1

It is creating back file from your original file.It will create with default value in every 10 min, you open in text editor.

In Ubuntu, gedit menu -> Preferences -> Editor, here you can find Create a backup of files before saving. Uncheck this option. Done

Another option: Autosave files every minutes..Here you can change it default value to 30 min or 1 hour.

Jitendra
  • 26
  • 3