rm wildcard not working
Try to match the dot:
$ rm -r .*.swp
I hope this solve your problem.
It's Bash
feature controlled by dotglob
shell option described in man page
:
If set, bash includes filenames beginning with a `.' in the results of pathname expansion.
As it's a Bash
feature it causes other commands such as grep
, ls
etc. do not handle files starting with .
if dotglob is not set as
well. You can check if dotglob
is set on your system using shopt
built-in, it must be off
if you experience such issues:
$ shopt | grep dotglob
dotglob off
If shopt
was set *
would match all files, even these starting
with .
. See this example:
$ touch a b c .d
$ ls *
a b c
$ ls *d
ls: cannot access '*d': No such file or directory
$ shopt -s dotglob
$ shopt | grep dotglob
dotglob on
$ ls *
.d a b c
$ ls *d
.d
When dotglob
is off you can still create a pattern to handle files
in the current dir together with hidden files:
ls .[!.]* *
or
ls .[^.]* *