I am trying to write a simple bash script that will copy the entire contents of a folder including hidden files and folders into another folder, but I want to exclude certain specific folders. How could I achieve this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use rsync:
Note that using
sourceandsource/are different. A trailing slash means to copy the contents of the foldersourceintodestination. Without the trailing slash, it means copy the foldersourceintodestination.Alternatively, if you have lots of directories (or files) to exclude, you can use
--exclude-from=FILE, whereFILEis the name of a file containing files or directories to exclude.--excludemay also contain wildcards, such as--exclude=*/.svn*