Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a directory on my linux os(Ubuntu) full of files that start with a tilde sign(e.g. example.txt~, example.py~). When I look at my directury using the regular gui I don't see any files there. But when I do ls in that directory I see such files. what do these files do and how do I get rid of them?

share|improve this question
    
What is the name of the directory? More common files contain tilde at the end (file.txt~), it is a traditional way of denoting backups. –  choroba May 21 '12 at 21:47
add comment

migrated from stackoverflow.com May 21 '12 at 23:24

This question came from our site for professional and enthusiast programmers.

7 Answers

up vote 1 down vote accepted

Since you seem to be having trouble, removing any file with a '~' anywhere in the file name would be as easy as adding another asterisk.

Example: rm *\~*

Strange that whatever application would place the tilde in the beginning of the file name, I've never seen that.

share|improve this answer
    
Forgot to mention that you should examine the permissions of the files and make sure you are allowed to remove them. I know some applications will return a "No such file or directory" if you're trying to execute them from a non privileged user account. Although I'm not sure about files... Good luck. –  Pizano May 21 '12 at 23:24
    
Thnx, this worked! –  Bentley4 May 22 '12 at 22:51
add comment

These are probably temporary or backup files.

Gedit will prepend a tilde to backup files

http://chrisjean.com/2009/02/09/getting-rid-of-tilde-files-in-ubuntu/

You are probably using a program that prepends a tilde for a similar purpose.

To delete them from the current directory

rm \~*

You can also use the -R flag of rm to remove recursively, but do so with caution...

share|improve this answer
    
When I do rm \~* in that directory I get rm: cannot remove '~*': No such file or directory. Any idea? –  Bentley4 May 21 '12 at 22:38
add comment

Tildes are generally used to indicate that the file is a backup copy of another file, so they're generally not shown in Nautilus and other file managers.

In your case, it looks like you were editing a few files in Emacs or Vim and had the editor's process terminated while you were editing them.

share|improve this answer
add comment

First cd to the directory, then to remove the files use:

rm -f ./~*

or

rm -f ./*~
share|improve this answer
    
If you were using VI and typed :wq~ instead of :wq! these tilde files show up. You can type vi ./~ and see the contents. Then, if it is the file you were editing, better do a mv ./~ myfilename.extension. Then you can go about moving the files around to the saved one. Otherwise you can just delete if you successfully did a :wq! after typing :wq~ on accident. –  CarComp Jul 12 '13 at 16:49
add comment

They were probably created by another program (or by accident from a mis-typed command).

If you really don't want them (you can open them up to make sure you don't need them), you can delete them just like any other file. Based on other answers it sounds like they're probably backup files.

The tilde is a special character, so you have to escape it with a backslash to refer to it from the command line.

You could delete them all with this command:

rm \~*

To view the contents of any one file, you could do this:

cat \~example.py
share|improve this answer
    
When I do rm \~* in that directory I get rm: cannot remove '~*': No such file or directory. The cat command does not work either. –  Bentley4 May 21 '12 at 22:29
    
It sounds like they don't exist. What arguments are you passing to ls? –  jahroy May 21 '12 at 22:36
    
They should exist, because when I do ls I can see them. –  Bentley4 May 21 '12 at 22:38
add comment

~ is often used to indicate backup or temporary files. That is why you probably can't see them in your GUI.

You can removed them with the shell command "rm", but before you do, you probably want to consider why they are there. Perhaps your GUI or some other tool you are running creates them and is relying on them - removing them from underneath the tool may have unintended consequences.

Any particular reason you think you need to remove them?

share|improve this answer
add comment

I found that in Linux Mint if you go ls ~backup in the home folder, it shows a list of files that dont exist in the home folder, but are actually in /var/backups.

So ls ~backup == ls /var/backups.
It appears as if ~backup is a hidden folder in $HOME (~) folder, but isn't.

ls ~backup -d shows /var/backups, so it must be a Symbolic Link called ~backup which is hidden, or something more complex.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.