Something like XCOPY on the Mac?

This is an answer to a question about how to recursively copy newer files from one directory to another with a Mac. By “recursively” I mean including sub directories. …Oh, and this is using the Unix shell in Terminal. (Remember, the easy way to get to Terminal is Command-Spacebar to open Spotlight and then type Terminal and open it.

xcopy C:/source X:/destination /e/s/d/y

In Windows, the above command does this and does not prompt when overwriting files.

My first thought was “cp -fuRp * /destination” but there is no -u parameter in OS/X! Egad.

So, then I thought of “rsync” and that seems to do the job:

rsync -aruv * /destination

This example assumes the directory you are copying from is the working directory.

-a Archive mode – retains file settings including dates
-r Recursive – subdirectories
-u Update – only copy newer files
-v Verbose

Remember! Don’t use “*.*” in unix. There are no Windows-style file name extensions.

Yes, it is different from Windows. Yes, it has to be learned to be used. Keep in mind that you had to expend effort to learn DOS/Windows commands and that Unix isn’t going away – what you learn will continue to be useful are a long time.

Be Sociable, Share!