Linux commands to copy one file to many files

后端 未结 9 1061
失恋的感觉
失恋的感觉 2020-12-23 11:10

Is there a one-line command/script to copy one file to many files on Linux?

cp file1 file2 file3

copies the first two files into the third.

9条回答
  •  眼角桃花
    2020-12-23 12:14

    You can use shift:

    file=$1
    shift
    for dest in "$@" ; do
        cp -r $file $dest
    done
    

提交回复
热议问题