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.
Use something like the following. It works on zsh.
cat file > firstCopy > secondCopy > thirdCopy
or
cat file > {1..100} - for filenames with numbers.
It's good for small files.
You should use the cp script mentioned earlier for larger files.
You can use shift
:
file=$1
shift
for dest in "$@" ; do
cp -r $file $dest
done
cat file1 | tee file2 | tee file3 | tee file4 | tee file5 >/dev/null