36

What is the file with the ~ at the end of the filename for?

$ ls # aliased to add flags
-rwxrwxr-x  1 durrantm  2741 May 16 09:28 strip_out_rspec_prep_cmds.sh~*
drwxrwxr-x 13 durrantm  4096 May 16 14:21 ../
-rwxrwxr-x  1 durrantm  2221 May 16 14:58 strip_out_rspec_prep_cmds.sh*

This is not the same as .swp files which are there while editing.

The two files have quite a few differences and the newer file (no ~ at the end) has the most recent changes and those changes are not in the older (~) file.

Looks like I can delete it?

Michael Durrant
  • 41,213
  • 69
  • 165
  • 232
  • Related: http://askubuntu.com/questions/173151/what-does-the-tilde-at-the-end-of-a-file-name-stand-for –  May 17 '13 at 13:17
  • 3
    This is a more canonical (clear, concise, and less localized) Q&A than the duplicate therefore should be reopened to replace it. See: http://meta.unix.stackexchange.com/questions/2840/which-duplicate-should-be-closed – goldilocks Apr 24 '14 at 16:31

2 Answers2

34

Typically files ending with a ~ are backups created by editors like emacs, nano or vi.

Eric Renouf
  • 18,141
  • 4
  • 49
  • 65
crowbent
  • 456
  • 4
  • 2
10

A tilde suffix is usually used for backup files. Vim and Emacs use this convention and probably many other programs, too. .swp files are vim swap files which are only present during editing of a file or in the case vim crashed.

Marco
  • 33,188
  • 10
  • 112
  • 146