匹配隐藏文件

制备

$ mkdir globbing
$ cd globbing
$ mkdir -p folder/{sub,another}folder/content/deepfolder/
touch macy stacy tracy "file with space" folder/{sub,another}folder/content/deepfolder/file .hiddenfile
$ shopt -u nullglob
$ shopt -u failglob
$ shopt -u dotglob
$ shopt -u nocaseglob
$ shopt -u extglob
$ shopt -u globstar

Bash 内置选项 dotglob 允许匹配隐藏文件和文件夹,即以 . 开头的文件和文件夹

$ shopt -s dotglob
$ echo *
file with space folder .hiddenfile macy stacy tracy