When I try to match all dot files in a directory with .*
it seems to have a nasty side-effect: besides matching all (real) files and directories, it matches .
and ..
.
bash-3.2$ mv test/.* dest/
mv: rename test/. to dest/.: Invalid argument
mv: test/.. and dest/.. are identical
This seems really weird, since they are basically 'fake' directories, just there to make relative paths easy. They are not part of the contents of a directory, and I don't ever want them matched when I try to move the contents of one directory to another directory. I can't think of any scenario where I would want them matched by .*
.
So how can I turn this off? (Besides using Z shell, which is not always available, and which may not be the shell in use by someone running a function I've written.)
Best Answer
You can use the
GLOBIGNORE
bash variable.and
So if you set
then
path/.*
will not match.
and..
, as you ask.