-2

If I'm in a directory like:

/home/usr_name/Documents/test

And, accidentally, I launch:

rm .*

What happens?
I thought it would remove all the files that contained a dot.. but I definitely was wrong!

SirDeveloper
  • 276
  • 1
  • 10

2 Answers2

2

It matches .* according to the globbing rules of your shell. For the shells I'm familiar with (bash, tcsh) it will match all files beginning with a dot. Use *.* for all files containing a dot or *. for all files ending with a dot.

In general, * matches any sequence of characters; however, it will not usually match a leading dot (i.e. * by itself won't match filenames beginning with a dot, but .* will).

davmac
  • 20,150
  • 1
  • 40
  • 68
1

When using rm and not sure about using wild characters *, always do a

ls .*  

whatever is the output, that is what rm is going to work on when you do a rm .*

brokenfoot
  • 11,083
  • 10
  • 59
  • 80