Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The command touch {jan,feb,mar}-{Rep.xls,graph.xls} creates files I can't open:

feb-graph.xls jan-Rep.xls feb-Rep.xls mar-graph.xls jan-graph.xls mar-Rep.xls

So I created one template file 1.ods, saved with OO-Calc. Then I tried to copy this file using cp again in the same fashion as cp:

cp 1.ods {jan,feb,mar}{Rep.ods,graph.ods}  

but that doesnt work:

cp: target `margraph.ods' is not a directory

How do I copy a single file to multiple files?

share|improve this question
when you give multiple args to cp it assumes you want to copy a lot of files to the last one -- which is then expected to be a directory; hence your error. – nik May 26 '11 at 15:19
So, you want to copy a single file to multiple new files in one command? – nik May 26 '11 at 15:20
up vote 13 down vote accepted

Combine cat (retrieves the contents of a file) with tee (writes the content away to the files specified in the arguments):

cat 1.ods | tee {jan,feb,mar}-{Rep,graph}.ods >/dev/null

Alternative using shell redirection:

tee {jan,feb,mar}-{Rep,graph}.ods >/dev/null < 1.ods

In both cases, > /dev/null is a redirection that discards the duplicated contents (tee writes its input to each parameter and standard output).

share|improve this answer
+1, nice too! I seem to be biased towards for-loops ;-) – nik May 26 '11 at 15:23
@nik: my previous answer included a for loop too, but this one-liner is more clear – Lekensteyn May 26 '11 at 15:26

How about,

for file in {jan,feb,mar}-{Rep.xls,graph.xls}
  cp 1.ods $file
share|improve this answer
How this is executable? What execution type or language or filetype is it needs to be? – Kangarooo Aug 4 '15 at 4:06
It is a bash script. This can be executed in a shell or save it to a .sh file and execute it – Rufus_12 Apr 12 at 7:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.