Cannot recursive copy a hidden directory - UNIX
I'm currently trying to recursive copy a hidden directory using this command
cp -r ../openshiftapp/.openshift .
It is not working.. what can be wrong?
On OS X you should use -R rather than -r. The man page (on Snow Leopard 10.6.8) says:
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.
The recursive option for the cp command would be used on directories, not files. The documentation states:
-R, -r, --recursive copy directories recursively
The OSX docs have more info, but don't suggest that the option can be used with files. Instead, it still mentions their use for copying directory contents:
-R If source_file designates a directory, cp copies the directory and the entire subtree connected at that point. If the source_file ends in a /, the contents of the directory are copied rather than the directory itself. This option also causes symbolic links to be copied, rather than indirected through, and for cp to create special files rather than copying them as normal files. Created directories have the same mode as the corresponding source directory, unmodified by the process' umask. In -R mode, cp will continue copying even if errors are detected. Note that cp copies hard-linked files as separate files. If you need to preserve hard links, consider using tar(1), cpio(1), or pax(1) instead.