Welcome to the Linux Foundation Forum!
Lab 10.2
Hi Everyone,
I am little bit confused with what is the difference with and without trailing . (dot) in rsync command in the LAB 10.2. It said "Note the . at the end of the command", and it makes me wonder why "." is needed in the end of this command. I tried without "." and don't see any difference. Can you please advise?
0
Comments
The trailing dot in the rsync destionaton stops the automatic creation of output directories. This helps make the rsync more specific as to where it will store files. Consider:
$ rm -fr /tmp/LFT*
$ rsync -avx LFT [email protected]:/tmp/LFT/
One would probably expect to see the output as /tmp/LFT/<files>
but the files will be in /tmp/LFT/LFT<files>
Not what I had in mind.
If we use the trailing dot, which stops directory creation the top level directory we can see rsync is not creating the top level directory.
$ rm -fr /tmp/LFT
$ rsync -avx FLT [email protected]:/tmp/LFT/. #--> generates an error
$ mkdir /tmp/LFT
$ rsync -avx LFT [email protected]:/tmp/LFT/. #--> the command works but still generates the extra directory
Now by refining the input specification to copy only the files:
$ rm -fr /tmp/LFT
$ mkdir /tmp/LFT
$ rsync -avx LFT/. [email protected]:/tmp/LFT/.
We get just the files from the original directory placed in the directory we created. This gives percise control where the files are placed.
Thank you very much.