38

I’ve searched all over the internet and everybody suggests the same thing - that adding --exclude=´.*´ should exclude hidden files and folders from an rsync. It doesn’t. I´ve also tried adding a slash and/or double quotes eg. --exclude=¨\.*¨ Nothing seems to work. AGH!! Would really appreciate some help.

69

Both versions you are showing are wrong. You need to use double quotes.

--exclude=".*"

works and excludes hidden files and directories.

If you only want to exclude hidden directories:

--exclude ".*/"

I use it on a daily basis for backups.

  • Yup that worked but only when I cut and pasted your snippet. For some reason my keyboard is not setup to type a standard double quote. Instead it does this ¨ – user289455 Jun 13 '14 at 19:15
  • 1
    You are using a keyboard with dead keys active. You need to press " and then follow it with the spacebar. – Rinzwind Jun 13 '14 at 19:16
  • Oh! That worked too! You wouldn't know how to turn that off would you? – user289455 Jun 13 '14 at 19:18
  • yes...switch keyboard to "english (us)" ;) – Rinzwind Jun 13 '14 at 19:19
  • 1
    @YaroslavNikitenko sorry. There is a confusion there. It should read "if you ONLY want to exclude hidden directories". – Rinzwind Nov 21 '18 at 14:03
2

I use this expression: --exclude=".[!.]*"

Does the job well for me excluding hidden files and directories.

0

--exclude="/.*" your \ is pointing the wrong way .

rsync -a --exclude="/.*" ./ /path/to/sync
  • 2
    There is no need for the / :) he is not using "'s. If he needed a / is should be at the end to exclude dirs. – Rinzwind Jun 13 '14 at 19:01
0

Open a text file exclude_me.txt and type the following: .[a-z]*

Then execute the following:

rsync -avh --exclude-from='exclude_me.txt' /path/of/Source /path/of/Destination

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.