0

I noticed a file with a .txt~ extension.

  • What does the ~ mean?
  • How can I open this file? It seems not to work with a text editor.
Karlo
  • 105
  • 5
  • 2
    Try to rename the file to SOMETHING.txt and see what happends when you open it with text editor. – MandiYang Mar 09 '21 at 18:59
  • 2
    Extensions (.txt) have no required meaning in Ubuntu. A text file can have any name and any extension, or no extension at all. Some file ending in .txt might be a text file...or might not. The system does not care. `~` is sometimes used to represent a backup file, sometimes a working file, sometimes something else. – user535733 Mar 09 '21 at 19:00
  • 2
    Gedit uses that to create a backup. – Rinzwind Mar 09 '21 at 19:02
  • 1
    It may be an older version of the file with the same name without the `~`. – user68186 Mar 09 '21 at 19:02
  • @yangmandi That seems to work! – Karlo Mar 09 '21 at 19:04
  • 1
    Related: [What does the tilde at the end of a file name stand for?](https://askubuntu.com/questions/173151/what-does-the-tilde-at-the-end-of-a-file-name-stand-for) – steeldriver Mar 09 '21 at 19:21
  • 1
    @HuHa’s answer provides the explanation. If you really want to open this backup file, use Gedit, click the open button, navigate to this file, and open it. – Enterprise Mar 09 '21 at 20:40

1 Answers1

5

That's an editor backup file. Many Linux/Unix editors create that when saving the file. It's the same file type as the file without the ~, so you can use the same program (typically an editor) to open it.

Please notice that on Linux filename extensions don't have the strong semantics that they have on Windows; it's more a convention than anything else. .txt is commonly used for text files, but you can give them any extension you like (thus the common README name which on Windows would be README.txt), so foo.txt~ can live peacefully side by side to its newer version foo.txt.

That's also why there is the file command that looks inside a file to classify it: Since there is no filename extension for executable files (unlike foo.exe on Windows), there is no way of knowing what a file foo might be.

Desktop file managers use a MIME type database to classify files by their extensions so they can start the correct application to open them, so it makes sense to follow the convention; but this is not enforced in any way.

HuHa
  • 3,131
  • 9
  • 13