Linux commands to copy one file to many files

后端 未结 9 1058
失恋的感觉
失恋的感觉 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 11:52

    The simplest/quickest solution I can think of is a for loop:

    for target in file2 file3 do; cp file1 "$target"; done
    

    A dirty hack would be the following (I strongly advise against it, and only works in bash anyway):

    eval 'cp file1 '{file2,file3}';'
    

提交回复
热议问题