Linux commands to copy one file to many files

user121196 picture user121196 · Mar 3, 2012 · Viewed 40k times · Source

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?

Answer

ruakh picture ruakh · Mar 3, 2012

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