オプション無しだと、cpコマンドではディレクトリ構造ごと(サブディレクトリを含めた状態で)コピーすることはできない。
もしディレクトリ構造とセットでコピーしたい場合は、「–parents」オプションを利用すると良いだろう。
cp --parents コピー元ファイル コピー先PATH
[root@test-centos7 ~]# cp /work/aaaaa.txt /bkup [root@test-centos7 ~]# ls -la /bkup 合計 4 drwxr-xr-x. 2 root root 22 7月 29 05:49 . drwxr-xr-x. 30 root root 4096 7月 29 05:48 .. -rwxr-xr-x. 1 root root 0 7月 29 05:49 aaaaa.txt [root@test-centos7 ~]# cp --parents /work/aaaaa.txt /bkup [root@test-centos7 ~]# ls -la /bkup 合計 4 drwxr-xr-x. 3 root root 33 7月 29 05:49 . drwxr-xr-x. 30 root root 4096 7月 29 05:48 .. -rwxr-xr-x. 1 root root 0 7月 29 05:49 aaaaa.txt drwxr-xr-x. 2 root root 22 7月 29 05:49 work [root@test-centos7 ~]# ls -la /bkup/work 合計 0 drwxr-xr-x. 2 root root 22 7月 29 05:49 . drwxr-xr-x. 3 root root 33 7月 29 05:49 .. -rwxr-xr-x. 1 root root 0 7月 29 05:49 aaaaa.txt
![すべてのUNIXで20年動くプログラムはどう書くべきか デプロイ・保守に苦しむエンジニア達へ贈る[シェルスクリプトレシピ集]](http://ecx.images-amazon.com/images/I/51opLnpg2vL._SL160_.jpg)