Include .dotfiles when expanding *

Posted on

Ever annoyed that you did something like

cp -r ~/foo/* .

only to discover that all the hidden dot-files inside foo/ where not copied along?

This is because shells (zsh and bash at least) exclude hidden files when expanding the wildcard character (*).

Zsh has an option [1] for you to include them:

setopt globdots

In bash it’s a bit different [2]:

export GLOBIGNORE=. 

Both mechanisms will again exclude the directories . and .. from being matched.

This will affect any command you type using wildcard (*) at the beginning of the matching pattern, like ls *, mv * and so on.


Leave a Reply

Your email address will not be published.