user121196 user121196 - 3 months ago 5
Linux Question

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?

Answer

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
Comments