On Thu, Feb 26, 2026 at 17:58:34 +0100, Michael wrote:
> On Thursday, February 26, 2026 5:22:54 PM CET, Greg Wooledge wrote:
> > Or are you saying that the /back/rhk directory doesn't exist yet, and
> > you want cp or rsync to create it?  Let's assume that one.
> > 
> >     cd /
> >     rsync -a rhk /back/
> > 
> > That's what I would use to create the /back/rhk directory during the copy.
> > The obvious alternative would be:
> > 
> >     mkdir /back/rhk
> >     cd /rhk
> >     rsync -a . /back/rhk/
> > 
> 
> i'm curiuous: why use cd/mkdir at all?
> 
> afaik both, cp and rsync work just fine without them:
> 
>        rsync -a /rhk /back/

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.

If I'm in the source directory, then I know the files and subdirs that
I see *right now* are the ones that will appear in the destination.

I have the same issue with symbolic linking, using ln.  It's so much
easier if I'm *in* the directory where the link's being created, so that
the link target I must pass to the ln command is the same one that will
be resolved when the link is used.  It even allows tab completion when
generating the link target argument, if I need it -- for example, to
make sure I have the correct number of ../ components.

Reply via email to