Before that (attribution lost in post) Greg Wooledge wrote:
On Thursday, February 26, 2026 04:35:49 PM Stefan Monnier wrote:

> > I find it much easier to get the commands right if I cd to the source
> > directory first.  With long and complicated pathnames, it can be
> > easy to get confused about exactly which directory component(s) will be
> > copied over, and which will only be traversed.

Aside: That does seem helpful!

> FWIW, to avoid having to guess if `rsync my/foo your/bar` will end up
> creating a `your/bar/foo` or not, I pretty much always pass to `rsync`
> file names that end in `/.`, as in:
> 
>     rsync -a my/foo/. your/bar/.
> 
> I find it much more robust than relying the subtle differences between
> when file names end in `/` and when they don't, or when the target dir
> already exists or not (which tend to bite me what I have to interrupt
> an `rsync` and restart it again, since the target will usually exist
> for the second run but not for the first).
> 
> It does require my creating `your/bar` manually beforehand, tho.

For anybody following along (or reading this in the future):

   * rsync does have the same -x option that cp has (to stay on one filesystem)

   * this is the part where I think (but am not sure) that the behavior differs 
between cp and rsync (from man rsync on Wheezy ;-) :

`
A trailing slash on the source changes this behavior to  avoid  creating  an  
additional  directory  level  at  the  destination.  You can think of a 
trailing / on a source as meaning "copy the contents of this directory" as  
opposed  to  "copy  the directory  by  name",  but in both cases the 
attributes of the containing directory are transferred to the containing 
directory on the destination.   In  other  words, each  of  the  following 
commands copies the files in the same way, including their setting of the 
attributes of /dest/foo:

       rsync -av /src/foo /dest
       rsync -av /src/foo/ /dest/foo
'

Reply via email to