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?
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?
You can improve/simplify the
for
approach (answered by @ruakh) of copying by using ranges from bash brace expansion:This copies
file
intofile1, file2, ..., file10
.Resource to check:
The simplest/quickest solution I can think of is a for loop:
A dirty hack would be the following (I strongly advise against it, and only works in bash anyway):
Does
count as a "one-line command/script"? How about
?
Or, for a slightly looser sense of "copy":