2008-03-25

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. One more thought: Pop music is enjoyable right away, but grows tiresome quickly. Classical music can take effort to learn to enjoy, but grows more enjoyable in time. So it is with shell commands - they take effort to learn and enjoy, but continue to pay dividends forever.

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.