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

前端 未结 22 2079
终归单人心
终归单人心 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条回答
  •  没有蜡笔的小新
    2020-12-02 04:03

    If all your target directories match a path expression — like they're all subdirectories of path/to — then just use find in combination with cp like this:

    find ./path/to/* -type d -exec cp [file name] {} \;
    

    That's it.

提交回复
热议问题