Copy whole folders with cp -R
Plain cp refuses directories; -R is the forgotten recursive flag that copies an entire tree — including dot files that Finder and some tools miss.
Run `cp -R ~/Projects/myapp ~/Backup/myapp` to copy the folder and everything inside it to a new location.
01Command
Command
$ cp -R ~/Projects/myapp ~/Backup/myapp
cp -R src/ src.bak/02What it does
-R copies directories recursively, preserving the tree structure; adding -p on top also keeps timestamps and permissions. One subtlety on macOS: a trailing slash on the source (src/ versus src) can change whether the contents or the folder itself is copied, so spell out the destination explicitly and verify with ls after important copies.
03Risk
!Warning: If the destination exists, `cp -R src dst` nests a copy inside it (dst/src); pick a fresh destination name to avoid accidental nesting.
04Undo
Undo
$ rm -rf ~/Backup/myapp05Sources
- cp — copy files (macOS)Evidence: Documents the -R recursive copy and the trailing-slash behavior on source directories.
Last verified: 2026-09-17 · Category: Files & Folders