On Fri, 12 Aug 2022 11:49:39 -0400 Amn <amnoje...@gmail.com> wrote: > In learning how to create shell script files, I have come across the > need to move/copy files from one HDD to an external HDD. In MS I > would just "copy c:*.doc b:alldocs", but in Linux is a bit different. > How do I do that in Linux? > Any help would be most appreciated.
First off, as you have probably realized, Unix (and Linux) has no drive letters (A:, C:, etc.). In your example, you copy to B:, which is almost always the second of two floppy drives. My advice will be more generic, though. First, in order to access any partition or a floppy drive, Unix must mount it. This can be done automatically (e.g. a minimal system mounted during the boot process) or manually. Or it may be done automatically upon insertion of a device (USB, CD-ROM, etc.). So the first question is, where is your external device mounted? In Debian, it would typically be mounted under /media, with some sort of descriptive name, e.g. /media/disk, /media/floppy, etc. The second question is, has the user got the necessary permissions to write to the target device? Your sample command assumes that the current working directory for both drives is set appropriately. That doesn't work in Unix. You have one current working directory, and that's it. For that and other reasons, you should probably use absolute paths (specified from the root directory down, e.g. /home/amn/, /media/disk/). Once you get all that sorted out, and possibly automated, it is a matter of using cp to make the copy. Or something else, depending on what you have in mind. This sounds suspiciously like a backup script, to be run from time to time. Do, by all means, get it working with cp. But then look at using rsync to eliminate redundant copies. -- Does anybody read signatures any more? https://charlescurley.com https://charlescurley.com/blog/