How do i make multiple copies of a file in the command line?
I want to make multiple copies of a file using the command line in one command.
Is there a way I can do it where the files will be named automatically without having to type file(1) file(2) file(3)? |
Code:
for FILE in `seq 1 10`; do cp file file$FILE; done |
thanks but, isn't there a more regular variation of a command line tool?
|
Quote:
|
I've used tee to copy files. I just have to manually enter the file numbers myself.
me@me:~/Desktop$ cp wavotmp3.sh | tee wavotm31.sh wavotmp32.sh wavotmp33.sh and I get: cp: missing destination file operand after `wavotmp3.sh' Try `cp --help' for more information. The files show up but, I get that error. Does anyone know why? I'm looking for something similar to similar to tee or cp so I don't stray to far from novice commands for now. |
Quote:
Code:
cp wavnotm3* . |
Thanks umarzuki but, that won't do it. I just want to be able to cp a file as many times as I want and have the comp number the copies for me.
kinda like saying: make me three copies of wavnot.sh Number them by yourself. I'm looking for something simpler than for FILE in `seq 1 10`; do cp file file$FILE; done |
Simple enough to create a script based on the above - pass file and count in as parms. Then it becomes as easy as something like "./copyit filename 10"
|
Quote:
If you're looking for something like: ./somecommand <options> Then like the previous poster said, throw what I've given you in a script that takes parameters afterwards of what you need or want. |
Code:
for FILE in {1..10}; do cp file file$FILE; done |
Quote:
So why not this: Code:
for F in {1..3}; do cp file file$F; done |
Quote:
Code:
$ echo '`seq 1 10`'|wc -c But the point is that it doesn't invoke an external command (seq). |
Quote:
|
Thanks a lot folks.
I've only written one script before. So, this will be fun. But, I also don't even understand the code very well. In fact, I have no idea how I would write this script. Could one of you give me more help on writing a script that would except number of copies as a variable. I can't even tell if "File" or "FILE" represent variables of the name of the file I want to copy. The craziest part of this is that I'm trying to figure out how to do this just so I can make useless scripts and learn how to adjust their permissions proficiently. |
In the snippet above FILE is a variable, and file is the
thing you want to copy all over the place. What it does is to produce a sequence of numbers from 1 to 10, and then copy file to file${FILE} (where ${FILE} is replaced with the number from 1 to 10) for each iteration of the for loop. |
All times are GMT -5. The time now is 07:50 AM. |