Apple Blog

Basic uses of the OS X terminal, copy files without using the Finder

I always like to remember that fortunately OS X has a Unix kernel and this brings us many advantages, we have an important part of a great operating system, seasoned with many improvements introduced by Apple. And it never hurts to know some little tricks that can be very useful when facing different problems that we can find in the handling of our computer.

Basic uses of the OS X terminal, copy files without using the Finder
Basic uses of the OS X terminal, copy files without using the Finder

One of them is file copying. Obviously, when copying a small number of files from one folder to another, the Finder more than meets expectations . No need to remember any commands, just drag and drop to copy the desired file or files, (with the Cmd key pressed, the files will be moved and deleted from their current location) but what risks do we run when copying huge amounts of files ? That in any eventuality, the operation is aborted, wasting valuable time.

Trying to recover files from a damaged hard disk can be tedious with this system, as OS X catalogs all the files to be copied first, and then moves on to the actual copy, so if an error occurs, the system will “leave everything as it was” and we will have lost valuable time . If we try to copy smaller files in smaller quantities, we will also lose time, as we will have to be vigilant about sending a “new package” of files.

But obviously there are some simple terminal commands to be able to copy a large number of files without having to worry about any of them being corrupted or any errors occurring during copying. Broadly speaking, there are three possible commands when copying from one location to another using the terminal. These are, cp, rsync and ditto . If you want to know the characteristics of each one of them, typing “man” in the terminal followed by the command, will explain its functionalities.

Basically, cp is the basic “Copy”, rsync is a bit more specific and functional and ditto is better handled when copying directories with many subfolders , as it handles directory hierarchies better, all this explained VERY well above. Depending on which one we choose, the nomenclature that should be followed is the following, since it will take care of all our needs when copying:

Once we have chosen the terminal command that best suits our needs, all that remains is to specify the source directory from which the files will be copied and the destination directory. To do this, if we do not know the correct “path”, the easiest way is to drag the folder to the terminal, as this will show us in full. Don’t forget to add “*” to the path it shows, so that it will copy all the files that are inside that folder. Something similar to this should appear in your terminal:

Cnet Reviews

Now only by specifying the destination path, (dragging the folder where we want to copy to the terminal, as we had done before) pressing “enter” we will get all the files and folders we have specified to be copied. The advantage of this process, as I said before, is that if an error occurs, it will show us in the terminal the same , it will tell us which files have been copied and which not. This way we can more easily determine which files are giving problems and speed up the process.

Via

Similar Posts