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?

2

2 Answers 2

34

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

2
  • OP asks what ~ means, not what programs might create such files. Please elaborate on what is the purpose of such files. Commented Jun 9, 2014 at 12:43
  • Also, vim creates .swp files. So the answer is not clear.
    – ado sar
    Commented Jul 22, 2023 at 22:34
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.

1
  • I suspect that Sublime (the editor) is also following this convention
    – BenKoshy
    Commented Aug 22, 2019 at 1:14

Not the answer you're looking for? Browse other questions tagged .