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

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

    I like to copy a file into multiple directories as such: cp file1 /foo/; cp file1 /bar/; cp file1 /foo2/; cp file1 /bar2/ And copying a directory into other directories: cp -r dir1/ /foo/; cp -r dir1/ /bar/; cp -r dir1/ /foo2/; cp -r dir1/ /bar2/

    I know it's like issuing several commands, but it works well for me when I want to type 1 line and walk away for a while.

提交回复
热议问题