16

At the end of a makefile I saw

rm -f *~ *.class

I understand the *.class, but what's *~?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Xodarap
  • 3,613
  • 3
  • 20
  • 16
  • 4
    See: http://stackoverflow.com/questions/4572809/what-does-the-bash-command-rm-do – camh Feb 02 '11 at 01:19
  • This question should be closed and one of it's duplicate's reopened instead: http://unix.stackexchange.com/questions/76189/what-does-the-tilde-mean-at-the-end-of-a-filename Since the duplicate is more canonical (see http://meta.unix.stackexchange.com/questions/2840/which-duplicate-should-be-closed). – goldilocks Apr 24 '14 at 16:33

1 Answers1

31

It's basically removing backup files.

*~ means all files ending in ~.

Many Unix/Linux systems programs create backup files that end in ~.

For example, the emacs and nano editors automatically save a backup copy of each file you edit. When it saves a file, the old version gets saved using the file name with a tilde (~) added to the end.

Vim will do the same if you put :set backup in your .vimrc.

*~ on Unix/Linux is like *.bak on Windows.

Mikel
  • 56,387
  • 13
  • 130
  • 149
  • Ah! I was overthinking it. Thought it was removing all home directories or something... – Xodarap Feb 02 '11 at 01:20
  • 20
    `~` only get expanded into a home directory if it appears at the start of a word. – Mikel Feb 02 '11 at 01:21
  • You should be very careful if you ever publish a website to exclude those file at all cost as one of the classical way to attack a website it to search those file that will be simply diplayed by your webserver as text files, and so reveal your server code (which is bad because no code are 100% reliable) – Kiwy Apr 24 '14 at 16:20