Bash – Copy all dotfiles except for `.git` and `..`

bashdot-fileswildcards

I am aware of using .[!.]* to refer to all dotfiles in a directory with the exception of .., but how might one refer to all dotfiles except for .. and .git? I have tried several variations on .[!.||.git]* and .[!.][!.git]* and the like, but none refer to the intended files.

Best Answer

You can use the the extended globbing in bash:

shopt -s extglob
ls .!(.|git)

This also matches ., though, so you probably need

ls .!(|.|git)
Related Question