Linux commands to copy one file to many files

后端 未结 9 1024
失恋的感觉
失恋的感觉 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:12

    Use something like the following. It works on zsh.

    cat file > firstCopy > secondCopy > thirdCopy

    or

    cat file > {1..100} - for filenames with numbers.

    It's good for small files.

    You should use the cp script mentioned earlier for larger files.

    0 讨论(0)
  • 2020-12-23 12:14

    You can use shift:

    file=$1
    shift
    for dest in "$@" ; do
        cp -r $file $dest
    done
    
    0 讨论(0)
  • 2020-12-23 12:15

    cat file1 | tee file2 | tee file3 | tee file4 | tee file5 >/dev/null

    0 讨论(0)
提交回复
热议问题