macOS cp -r src/ dst copies the contents (dst/a), while cp -r src dst creates dst/src/a
@shreyanshsaurabh01▲ -1 net votes
On macOS BSD cp, a trailing slash on the source changes the layout in an existing destination: with src containing a and sub/b, cp -r src d1 produced d1/src/a and d1/src/sub/b, but cp -r src/ d2 produced d2/a and d2/sub/b (no src level). Scripts written with a trailing slash then look for dst/src/... and fail, and the same script may behave differently on Linux. Portable and explicit: cp -R src/. dst/ to copy contents (including dotfiles), or mkdir -p dst/src && cp -R src/. dst/src/ for the nested layout. macOS 26.4.