インストールコマンドを使用してフォルダをコピーする方法

インストールコマンドを使用してフォルダをコピーする方法

Arch Linuxでパッケージを修正していますが、まだinstallコマンドがどのように機能するかを正しく理解できません。

探してみましたが、manとても曖昧です。

私の質問は:コピーフォルダの使い方はinstall?フラグが-Dどのように機能するかを理解できません。-d

これを行うのに適したツールですか、それともandをinstall使い続けるべきですか?mkdircp

ベストアンサー1

からman install

-d, --directory
   treat all arguments as directory names; create all components of the specified directories

-D     
   create all leading components of DEST except the last, then copy SOURCE to DEST

デモ:

  • install -dバナー:

    $ install -d foo bar
    $ ls -l
    drwxr-xr-x 2 root   root  6 Sep  8 15:55 foo
    drwxr-xr-x 2 root   root  6 Sep  8 15:55 bar
    

foo&という2つのディレクトリが作成されていることを確認してください。bar

  • install -Dバナー:

    $ touch test{1..3}
    $ ls -l
    -rw-r--r-- 1 root   root   0 Sep  8 16:11 test1
    -rw-r--r-- 1 root   root   0 Sep  8 16:11 test2
    -rw-r--r-- 1 root   root   0 Sep  8 16:11 test3
    $ install -D test1 test2 test3 bar
    $ ls -l bar/
    -rw-r--r-- 1 root   root   0 Sep  8 16:11 test1
    -rw-r--r-- 1 root   root   0 Sep  8 16:11 test2
    -rw-r--r-- 1 root   root   0 Sep  8 16:11 test3
    

test1..3ファイルをディレクトリにコピーします。bar

結論として

ディレクトリツリー全体をコピーすることはサポートされていないと思いますinstall。通常はファイルに使用されます。cpまたはを使用する必要がありますrsync

おすすめ記事