Last Updated: February 25, 2016
·
750
· tfnico

Include .dotfiles when expanding *

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.

[1] http://zsh.sourceforge.net/Intro/intro_16.html
[2] http://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html