리눅스 cp -r

1 개요[ | ]

리눅스 cp -R
리눅스 cp -r
리눅스 cp --recursive
  • 리눅스 cp 명령어의 옵션 중 하나
  • 폴더들을 재귀적으로(recursively) 복사함
  • 하위폴더들을 깊이있게 끝까지 모두 둘러보며 폴더와 파일을 복사함
  • 단, 명령어를 수행한 계정이 폴더 및 파일의 소유자가 되며, 퍼미션도 umask에 따라 새로 부여됨
소유자, 퍼미션까지 원본과 완전히 동일하게 하려면 cp -a를 이용하는 것이 좋다. ★

2 예시[ | ]

root@zetawiki:~# tree webroot
webroot
├── menu1.html
└── pages
    ├── page1.html
    └── page2.html

1 directory, 3 files
root@zetawiki:~# tree webroot-overlay
webroot-overlay
├── index.html
└── pages
    ├── page2.html
    └── page3.html

1 directory, 3 files
root@zetawiki:~# diff -r webroot webroot-overlay
Only in webroot-overlay: index.html
Only in webroot: menu1.html
Only in webroot/pages: page1.html
diff -r webroot/pages/page2.html webroot-overlay/pages/page2.html
1c1
< hello
---
> world
Only in webroot-overlay/pages: page3.html
root@zetawiki:~# cp -r webroot-overlay/* webroot/
root@zetawiki:~# tree webroot
webroot
├── index.html
├── menu1.html
└── pages
    ├── page1.html
    ├── page2.html
    └── page3.html

1 directory, 5 files
root@zetawiki:~# cat webroot/pages/page2.html 
world

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}