4 ms·
The trailing slash behavior totally makes sense. It only took me a couple of times for me to learn it. Unfortunately, it took only one more time for it to be f
by sfink 6y ago
The trailing slash behavior totally makes sense. It only took me a couple of times for me to learn it.
Unfortunately, it took only one more time for it to be forgotten, then another few times to be re-learned, then forgotten again, then half-remembered the wrong way, then....
I pretty much have it down now, though. The secret to my success: remembering that the differing behavior applies to the source side only. Trying to work out the matrix of possibilities between source, source/, dest, and dest/ is where I usually got lost, until I finally got it through my head that the destination syntax is irrelevant.
Now it makes sense: "foo/bar/" is the directory named "bar"; "foo/bar" is the directory entry within foo/ named "bar". Copying a directory puts its contents on the destination side. Copying a named thing, whether the name refers to a file or directory, puts that name on the destination side.
- recursive 6y agoI've never used rcp or rsync, but your final explanation provides no illumination for me. "foo/bar/" and "foo/bar" are both directories named "bar". Copying a thing puts that thing on the destination side. It still doesn't sound like there's a difference.
- dcassett 6y agofoo/bar/ and foo/bar are not the same if bar is a symbolic link. You can see the difference using 'ls -l'
- hanche 6y agoMy understanding is that "foo/bar/" is considered a short form of "foo/bar/.". Interpreting that forces following the symlink.
- hanche 6y agoI think it makes more sense to say that, for rsync, "foo/bar/" names the contents of the directory, while "foo/bar" names the directory itself. You could perhaps think of "foo/bar/" as a shortcut for "foo/bar/*", except that it matches hidden files as well.
- dylan604 6y agoYeah, that happens to me on anything that gets used, put back up on the shelf, and then pulled back down again after some period of not being used. However, rsync has become the go to tool for getting local content to/from a server.
- perennialmind 6y agoLately I've taken to avoiding that fine point. I find it easier to internalize `foo/bar/.`. Using the self-referential dot this way doesn't carry the same semantics, but the effect is the same and it's a pattern that applies to many tools. rather than consult the manpage yet again. When I want those semantics, I tack on the self-referential dot. `rsync foo/bar/. baz`
- b0afc375b5 6y agoThanks for the explanation, I've also struggled with this in the past. Hopefully I remember it This Time™.