Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have directory loaded with thousands of sub directories:

/home/tmp/
          1
          12
          123
          1234
          2345
          234
          3456
          345
          34

Each subdirectory in turn has hundreds of subdirectories that I want to rsync if the first level subdirectory matches...

What I need is a way to copy/rsync only the directories that start with a given digit [1-9]...

What I think I want is basically something that would allow me to use wild cards to match

rsync -rzvvhP remotehost:/home/tmp/1* /home/tmp/

I want rsync to sync up the

/home/tmp/1/
/home/tmp/12/
/home/tmp/123/
/home/tmp/1234/

directories and any child subdirectories they have but not any of the first level directories that start with a different digit...

/home/tmp/234/
/home/tmp/2345/
........./3*/
........./4*/ etc..

What I've tried:

rsync -rzvvhP --exclude='*' --include-from=1.txt remotehost:/home/tmp/ /home/tmp/

where 1.txt contains:

1
12
123
1234

When I do this with 2.txt though rsync still seems to run through all the directories that start with 1 and 3 etc...

How can I do this so that I can have one command to rsync only the directories that start with any given digit?

share|improve this question
    
Why wouldn't /home/tmp/1* work? –  KayEss Feb 25 '13 at 4:44

1 Answer 1

You can try something like this for your wildcard:

/home/tmp/{1,12,123,1234}

The {} generates each of the comma separated options so is equivalent to this:

/home/tmp/1 /home/tmp/12 /home/tmp/123 /home/tmp/1234
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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