How to copy a file to multiple directories using the gnu cp command

前端 未结 22 2070
终归单人心
终归单人心 2020-12-02 03:25

Is it possible to copy a single file to multiple directories using the cp command ?

I tried the following , which did not work:

cp file1 /foo/ /bar         


        
22条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 04:14

    if you want to copy multiple folders to multiple folders one can do something like this:

    echo dir1 dir2 dir3 | xargs -n 1 cp -r /path/toyourdir/{subdir1,subdir2,subdir3}

提交回复
热议问题