exclude a pattern but only in the top level

Brian K. White brian at aljex.com
Wed May 15 10:39:22 MDT 2013


On 5/15/2013 8:35 AM, Paul Slootman wrote:
> On Wed 15 May 2013, Brian K. White wrote:
>
>>> rsync -avz /foo/ ${DEST}::root/foo/
>>
>> This syntax does work in his case, and is easier to read, because it
>> ends up using the exact same specification "/foo/" and "/foo/" for
>> both source and dest, but the syntax I had was also correct. I no
>> longer remember why I always do the way I posted, but I've been
>> doing it that way for decades (if you count rcp before rsync).
>
> My reasoning is that if you're transferring a directory, make that
> obvious by specifying a trailing slash. But use whatever you're happy
> with, just don't complain if things get confusing (which it looked like
> was the problem).



>
>
>> The -f ". filename" syntax is correct it's right in the manual and
>> I've been using it for ages.
>
> Well, -f specifies a filter rule. You're using -f to specify a filter
> rule to tell rsync to merge in a file with additional filter rules,
> which is a bit of a roundabout way. Why not tell rsync directly to read
> a file with include/exclude rules by using --exclude-from

I did in the case when it was only one pattern, but that was just a 
simplified example.

The actual job involves too many include and exclude patterns to use 
--include & --exclude, or even --include-from and --exclude-from, 
because the patterns are generated on the fly by a script from values 
supplied on the script commandline or hardcoded at the top, and for each 
of those values several different include and exclude patterns are 
generated, and, the order they appear in the filter file matters, I need 
to write the filter file so that certain things get included before 
others, and all the includes & excludes aren't necessarily together in 
two contiguous blocks.

-f ". filename" is actually the simplest and neatest way to express the job.

-- 
bkw



More information about the rsync mailing list