Brian J. Murrell
2026-Jan-30 13:23 UTC
Copying one directory tree to another but exclude all top-level files
Hi. I want to do this: # rsync -aSPAHX --exclude \* --link-dest=/.snapshots/daily.10/ ../daily.10/ . so that any *files* in the /.snapshots/daily.10/ directory (but not any directories in /.snapshots/daily.10/ and directories and files below that) are excluded? Using the above syntax, nothing gets copied I suppose because * matches all of the top-level directories in /.snapshots/daily.10/ also. Cheers, b.
Kevin Korb
2026-Jan-30 13:56 UTC
Copying one directory tree to another but exclude all top-level files
It sounds like you want: --include='/*' --exclude='/*/' but I am having a bit of trouble understanding your goal.? You are right though that an exclude of * means exclude everything. BTW, a second -v enables include/exclude debugging. On 2026-01-30 08:23, Brian J. Murrell via rsync wrote:> Hi. > > I want to do this: > > # rsync -aSPAHX --exclude \* --link-dest=/.snapshots/daily.10/ ../daily.10/ . > > so that any *files* in the /.snapshots/daily.10/ directory (but not any > directories in /.snapshots/daily.10/ and directories and files below > that) are excluded? > > Using the above syntax, nothing gets copied I suppose because * matches > all of the top-level directories in /.snapshots/daily.10/ also. > > Cheers, > b. >