In my deployment script I have such as code to exclude certain files.

shopt -s extglob
mv !(deploy.sh|file1|file2) ~/$public

It works almost well but ignores hidden files so they are not moved. How to improve the code to move hidden files too?


There is a dotglob option in bash exactly for this purpose:

$ touch file1 file2 .file
$ ls !(file1)

$ shopt -s dotglob
$ ls !(file1)
.file  file2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.