multiple copies at once


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers multiple copies at once
# 1  
Old 12-16-2008
multiple copies at once

Dear all,
Today I spend almost all my day with something I hope any of you can help me with...
I'm trying to write a small script (!/bin/sh) to be able to make 900 copies of one file. Can anyone help me with this? I couldn't figure this out (maybe I need to create some sort of loop) and couldn't find a solution on the net either.
Thank you so much in advance,

Marjolein
# 2  
Old 12-16-2008
Tools Why would you want to?

If there can be a reason, how to differentiate between the files? There can only be one file called sample.txt -- so how should the copies be named?
# 3  
Old 12-16-2008
Maybe this will get you started.

Code:
for ((i=0;i<900;i++)); do
 echo "do something $i.";
done

I have to ask, why do you want 900 copies of a file??
# 4  
Old 12-16-2008
I want to do this in order to create a so-called 4Dimensional data set (in time) of functional MRI data.
I will merge the 900 copies of the same 2D (.img) image together in 1 new 4D image. Since all the copies are identical, the name is not important.
# 5  
Old 12-16-2008
Tools OK, maybe this will get you to your result

Create a sample file
Code:
> cat file120
unix.com website

A command to do something (duplicate the file) 900 times
Beware if the file .new already exists since the >> will append to existing file. Thus, you might need to delete the .new file before executing the command.
Code:
> for ((i=0;i<900;i++)) do cat file120 >>file120.new; done

Take a look, and see the new file has 900 lines (as verification)
Code:
> wc -l file120.new
900 file120.new

Take a look at first ten rows to see that the original data was repeated
Code:
> head file120.new
unix.com website
unix.com website
unix.com website
unix.com website
unix.com website
unix.com website
unix.com website
unix.com website
unix.com website
unix.com website

# 6  
Old 12-16-2008
thanks!
i will try the suggestions at work tomorrow (i don't have vmware at my computer at home). i will let you know if it works!
# 7  
Old 12-17-2008
Unfortunately.... I did not succeed.
With Joeyg's advice I copied the content of the file 900 times, but not the file itself.

Ikon's advice was a little too short for a starter like myself.

Anyone other ideas?

Thanks so much in advance!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Finding copies of files

theres a situation i'm dealing with where i feel like folks are stealing some of my files. they copy it (because they have complete sudo root access like i do) from my home directory and they copy it wherever and then change the name of the file so i wont know that they have it. is there a way... (1 Reply)
Discussion started by: SkySmart
1 Replies

2. Shell Programming and Scripting

Tar creating copies of files

I am trying to archive directories based on their last modified date. When I tar and compress the directory it makes copies of whats inside, I don't know how to fix this. Here is my code. #!/bin/bash #AUTODRUNDISABLE VERSION="0.2" cd /desired/directory/to/archive find . -type d -newermt... (3 Replies)
Discussion started by: jrymer
3 Replies

3. Shell Programming and Scripting

How to make multiple copies?

At work I have to create multiple copies of a file all the time. Example: I have a file called Sec30p01.txt I need thirty of these, then I edit one line in each to make 30 different control files. So I end up with Sec30p02.txt, Sec30p03.txt and so on up to 30 Currently I copy the first file... (8 Replies)
Discussion started by: faaslave
8 Replies

4. Shell Programming and Scripting

Print multiple copies page by page using lp command

Hi I have a pdf file that is being generated using the rwrun command in the shell script. I then have the lp command in the shell script to print the same pdf file. Suppose there are 4 pages in the pdf file , I need to print 2 copies of the first page, 2 copies of the second page , then 2... (7 Replies)
Discussion started by: megha2525
7 Replies

5. Shell Programming and Scripting

Help configuring sudo for multiple file copies

Hiya, I want to allow some users to copy all filenames of a specific filetype, to a limited directory. 3+ users: need to be able to copy(as root) any *.war file to /usr/local/tomcat/current/webapps/ I tried the following... dmurphy huskar=/tmp/who.sh,/bin/cp *.war... (2 Replies)
Discussion started by: infinitiguy
2 Replies

6. Homework & Coursework Questions

Script that copies one file to/over another

1. The problem statement, all variables and given/known data: Write a script that asks for 4 arguments, and the 1st and 3rd need to be -i and -o, and the 2nd/4th need to be file names. Technically, it's supposed to be run as: ./Lab_14.sh -i input.txt -o output.txt Depending on how many... (0 Replies)
Discussion started by: SoVi3t
0 Replies

7. UNIX for Dummies Questions & Answers

Printing Multiple Copies

Has anyone come accross and solved an issue where only 1 copy of a doc prints after you use the -n flag and specify more then 1. My exact syntax is lp -dprintername -n3 documentname enq command does same thing. Both commands show the 3 copies in the queue but only 1 ever prints I am using AIX... (0 Replies)
Discussion started by: capeme
0 Replies

8. Shell Programming and Scripting

Script to print multiple copies of the same file

Hi, this is my first post so I hope I have placed it in the appropriate section! I have created a looping script to print a text file multiple times. The script works great, and it displays the job numbers of all the prints that result from its execution. The trouble is, only the first job... (1 Reply)
Discussion started by: Alpha7
1 Replies

9. AIX

Printing multiple copies via remote queue

Hi all, I have an interesting problem. Using remote queues to print using jetdirect printers I am unable to get a printer to print multiple copies of a print job. command being used: lpr -P -#3 ./test (one copy prints) Also tried: enq -P -C3 ./test (same results) Any ideas? ... (6 Replies)
Discussion started by: Luck
6 Replies

10. UNIX for Advanced & Expert Users

lp not printing multiple copies

I'm trying to print multiple copies of a file on sun solaris 8 with the lp -n command to no avail. No matter what numeric value I supply -n, I still only get 1 copy of the file printed. The command I'm using is 'lp -d SNY_IT5000-2 -n2 file' The printer is an HP Laserjet 4000 with a... (2 Replies)
Discussion started by: hassan2
2 Replies
Login or Register to Ask a Question