Search code examples
linuxcp

Linux commands to copy one file to many files


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. Is there a way to copy the first file into the rest?


Solution

  • Does

    cp file1 file2 ; cp file1 file3
    

    count as a "one-line command/script"? How about

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

    ?

    Or, for a slightly looser sense of "copy":

    tee <file1 file2 file3 >/dev/null