Say I want to copy all files within dir to dest:
$ tree .
.
├── dest
└── dir
├── dir
│ ├── file1
│ └── file2
└── file3
This is easy if I know the filenames and the directory depths:
$ echo dir/f* dir/*/*
dir/file3 dir/dir/file1 dir/dir/file2
$ cp dir/f* dir/*/* dest/
$ tree dest/
dest/
├── file1
├── file2
└── file3
It's also easy (with globstar) to get only the directories:
$ echo dir/**/*/
dir/dir/
But I don't know how to glob only the files, e.g. the following doesn't work:
$ echo dir/**/*!(/)
dir/**/*!(/)
One option is to use
findwith-type foption: