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

前端 未结 22 2032
终归单人心
终归单人心 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:10

    ls -db di*/subdir | xargs -n 1 cp File

    -b in case there is a space in directory name otherwise it will be broken as a different item by xargs, had this problem with the echo version

提交回复
热议问题