Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Copying directories in Linux and MacOS
ykk@peruna:/tmp/copytest$ uname
Linux
ykk@peruna:/tmp/copytest$ ls -lR
.:
total 0
drwxr-xr-x 2 ykk ykk 40 Sep 26 09:19 bar/
drwxr-xr-x 2 ykk ykk 100 Sep 26 09:16 foo/
./bar:
total 0
./foo:
total 0
-rw-r--r-- 1 ykk ykk 0 Sep 26 09:16 one
-rw-r--r-- 1 ykk ykk 0 Sep 26 09:16 three
-rw-r--r-- 1 ykk ykk 0 Sep 26 09:16 two
ykk@peruna:/tmp/copytest$ cp -r foo/ bar
ykk@peruna:/tmp/copytest$ ls -lR
.:
total 0
drwxr-xr-x 3 ykk ykk 60 Sep 26 09:19 bar/
drwxr-xr-x 2 ykk ykk 100 Sep 26 09:16 foo/
./bar:
total 0
drwxr-xr-x 2 ykk ykk 100 Sep 26 09:19 foo/
./bar/foo:
total 0
-rw-r--r-- 1 ykk ykk 0 Sep 26 09:19 one
-rw-r--r-- 1 ykk ykk 0 Sep 26 09:19 three
-rw-r--r-- 1 ykk ykk 0 Sep 26 09:19 two
./foo:
total 0
-rw-r--r-- 1 ykk ykk 0 Sep 26 09:16 one
-rw-r--r-- 1 ykk ykk 0 Sep 26 09:16 three
-rw-r--r-- 1 ykk ykk 0 Sep 26 09:16 two
...
ykar@fl049:/tmp/copytest$ uname
Darwin
ykar@fl049:/tmp/copytest$ ls -lR
total 0
drwxr-xr-x 2 ykar wheel 64 Sep 26 09:18 bar/
drwxr-xr-x 5 ykar wheel 160 Sep 26 09:15 foo/
./bar:
./foo:
total 0
-rw-r--r-- 1 ykar wheel 0 Sep 26 09:15 one
-rw-r--r-- 1 ykar wheel 0 Sep 26 09:15 three
-rw-r--r-- 1 ykar wheel 0 Sep 26 09:15 two
ykar@fl049:/tmp/copytest$ cp -r foo/ bar
ykar@fl049:/tmp/copytest$ ls -lR
total 0
drwxr-xr-x 5 ykar wheel 160 Sep 26 09:19 bar/
drwxr-xr-x 5 ykar wheel 160 Sep 26 09:15 foo/
./bar:
total 0
-rw-r--r-- 1 ykar wheel 0 Sep 26 09:19 one
-rw-r--r-- 1 ykar wheel 0 Sep 26 09:19 three
-rw-r--r-- 1 ykar wheel 0 Sep 26 09:19 two
./foo:
total 0
-rw-r--r-- 1 ykar wheel 0 Sep 26 09:15 one
-rw-r--r-- 1 ykar wheel 0 Sep 26 09:15 three
-rw-r--r-- 1 ykar wheel 0 Sep 26 09:15 two
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment