[SOLVED] How to copy file from one usb to another usb using rsyc in terminal?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: native install of Parrot Home Edition 5.0 Debian (no security tools) 64 bit, KDE, 5.14.0-9parrot1,
Posts: 872
Original Poster
Rep:
Quote:
Originally Posted by michaelk
A trailing slash after the source directory will copy the contents. No trailing slash copies the directory itself.
If the source contains directories and .txt, and I want all of them in to the external drive directory named 'new folder, should we slash or not slash in this case for the source?
Haven't tried the first option you provided i.e. without trailing slash the directory. They look the same to me. I wouldn't mind doing a rsync dry-run on the first option so I can see the difference between the 2 options you provided i.e. without trailing slash the directory, would that look anything like this
no, all the short options started with a -, long options with --, so it is --dry-run.
But anyway, it is you who need it and you can check if it works for you as expected.
This is a slightly different question to the one I asked a while back.
If I want to rsync everything on a usb called /media/asus/781E-438F to a directory called 'new folder' on an external drive named One Touch. Would the terminal command look like this?Thanks in advance.
NO.
That command would create a directory "/media/asus/One Touch/new folder/781E=438F/ and place the content of the source in that folder. As used the source directory and its content would be copied to the destination.
Changing that to read
would copy only the content of "781E-438F" to the directory "new folder".
You really need to read the man page for rsync, then make some trials to understand how that command interprets the source and what it does.
Source in the form "directory/" says to copy the content of "directory/" to the destination.
Source in the form "directory" says to copy the "directory" and all its content to the destination.
Distribution: native install of Parrot Home Edition 5.0 Debian (no security tools) 64 bit, KDE, 5.14.0-9parrot1,
Posts: 872
Original Poster
Rep:
Quote:
Originally Posted by computersavvy
NO.
That command would create a directory "/media/asus/One Touch/new folder/781E=438F/ and place the content of the source in that folder. As used the source directory and its content would be copied to the destination.
Changing that to read
would copy only the content of "781E-438F" to the directory "new folder".
You really need to read the man page for rsync, then make some trials to understand how that command interprets the source and what it does.
Source in the form "directory/" says to copy the content of "directory/" to the destination.
Source in the form "directory" says to copy the "directory" and all its content to the destination.
A directory is a location for storing files on your computer?
A source directory is one that contains the source location for files on your computer?
If the source directory is the usb stick named "781E-438F" and
the contents are the folders within the usb stick "781E-438F" then
what benefit is there to rysnc the source if I know already the source of what I am copying over?
In my case the source directory is the files within a usb named "781E-438F", is that correct? If yes, then how is that any different from just rsync the contents of usb named "781E-438F"?
If I had instead went ahead and done rsync source directory plus the contents with the usb named "781E-438F" I would have ended up with what as a bonus (other than the contents)? The code for that would have looked like this below:
Would there have been any additional benefit conferred upon me if I had went with rynsc source directory plus the contents (as above) vs just rysnc the contents (which is what I went for)?
Would there have been any additional benefit conferred upon me if I had went with rynsc source directory plus the contents (as above) vs just rysnc the contents (which is what I went for)?
I don't really understand, copying a directory means you will create another directory somewhere else (using the same name) and copy all the content from the source directory to the target directory.
Copying the content is almost the same, just you won't create a new [target] directory, but you specify an existing one.
Distribution: native install of Parrot Home Edition 5.0 Debian (no security tools) 64 bit, KDE, 5.14.0-9parrot1,
Posts: 872
Original Poster
Rep:
Quote:
Originally Posted by pan64
...copying a directory means you will create another directory somewhere else (using the same name) and copy all the content from the source directory to the target directory.
The name in this case is the name of the usb stick which in my case is "781E-438F". All content you copy over will end up looking like this e.g.
Code:
781E-438F/file-1
781E-438F/file-2
I was trying to say, I don't see how copying the source directory name (781E-438F) along with everything else is important? I don't see why I need it.
and look at the content of "/media/asus/new folder" to see what exactly happened. (It should contain a directory "/media/asus/new folder/781E-438F")
Then repeat using
and again look at the content of "/media/asus/new folder". This time it should contain only the content of the source 781E-438F directory. (assuming you cleaned out the data copied in the first time)
No one is saying to copy the directory and content. We are explaining how rsync works and saying that if you only want the content to be copied then you must use the form that has the trailing / on the source directory name (my second example here)
Last edited by computersavvy; 12-10-2023 at 08:10 PM.
The name in this case is the name of the usb stick which in my case is "781E-438F". All content you copy over will end up looking like this e.g.
Code:
781E-438F/file-1
781E-438F/file-2
I was trying to say, I don't see how copying the source directory name (781E-438F) along with everything else is important? I don't see why I need it.
In the linux/unix world everything is [mapped to] a file or directory, the OS itself works only on files and directories. So the question is if you want to appear the name (781E-438F) on the target side (as a directory). It depends on you, if you need it or if you find it annoying.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.