5

I just want to copy a folder tree to another place like this:

cp -avr /blah/blah/htdocs ./

but I got error:

cp: the -R and -r options may not be specified together.

I followed this tutorial: http://www.cyberciti.biz/faq/copy-folder-linux-command-line/ It's about Linux, while I am using Mac. I found I can work around by using -avR instead. However, I am wondering why -avr could result in the odd error on Mac.

Rob Lao
  • 1,031

2 Answers2

3

OS X is not Linux, but closer to BSD. According to the man page, there's no -r switch on cp for OS X. There used to be one, yet:

Historic versions of the cp utility had a -r option. This implementation supports that option; however, its use is strongly discouraged, as it does not correctly copy special files, symbolic links, or fifo's.

Daniel B
  • 62,883
2

This works for me:

$ cp -iprv SOURCE NEWDIRECTORY

Thanks to http://befused.com/freebsd/copy-directory

-iprv are options for the cp command:

  • i - Interactive. Prompt you if overwriting any files
  • p - Preserve file attributes like date, time, etc
  • r - Recursive. Will copy subdirectories
  • v - Verbose. Show you each file as it is copied in the command line console
bdanin
  • 121