Copy 1 file 5000 times and Rename each +1

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copy 1 file 5000 times and Rename each +1
# 1  
Old 09-24-2009
Copy 1 file 5000 times and Rename each +1


Found lots of stuff that is close but no cigar...

I have a file ie. a.txt, and I want to copy it to another directory 5000 times and call it:

Struggling to put a loop together in this new world of AIX. please include full script for me to understand and learn from.
Thanks in advance
# 2  
Old 09-24-2009
how about

in bash:

for i in {1..5000}
  echo $i

or something like

while [ $i -le 5000 ]
  echo $i

# 3  
Old 09-24-2009
for ((i=1;i<=5000;i++)); do
  cp -p a.txt urnewdir/a${i}.txt

# 4  
Old 09-24-2009
while [ $n -le 5000 ]
        cp a.txt ../a$n.txt
        n=$(( n+1 ))

../a$n.txt will copy on the parent directory where the script is executed, put whatever you want as a full path for instance.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Modification of perl script to split a large file into chunks of 5000 chracters

I have a perl script which splits a large file into chunks.The script is given below use strict; use warnings; open (FH, "<monolingual.txt") or die "Could not open source file. $!"; my $i = 0; while (1) { my $chunk; print "process part $i\n"; open(OUT, ">part$i.log") or die "Could... (4 Replies)
Discussion started by: gimley
4 Replies

2. Shell Programming and Scripting

Bash to copy file 3 times and rename based on another file

In the below bash I am trying to copy the only text file (always only one) in /home/cmccabe/Desktop/list/QC/metrics.txt and rename each of the 3 text files according to /home/cmccabe/Desktop/test/list.txt using lines 3, 4 ,5. This format (that is list.txt) is always 5 lines. Thank you :). ... (12 Replies)
Discussion started by: cmccabe
12 Replies

3. Shell Programming and Scripting

Copy n paste n times

I have one mainframe copy book where I want to copy n times depend on occurs which mention below. Example: Below highlighted row mention “occurs 2 times” so I need to copy 2 times till next label 10. C14992 10 FILLER PIC X(2835). 01 ... (7 Replies)
Discussion started by: srivalli
7 Replies

4. UNIX for Dummies Questions & Answers

How to copy set of lines n times?

I have a file with following data A B C I would like to print like this n times(For eg:n times) A B C A B C A B C A B C A (3 Replies)
Discussion started by: nsuresh316
3 Replies

5. Shell Programming and Scripting

Need help in writitng a script to rename file name and copy to other folder

Hi All, My requirement is as follows: A file (say abc) will be having list of the .txt file names. I need to read this abc file line by line and rename the .txt file names inside it and move them to other folder/path. Eg: abc ------- file1.txt file2.txt file3.txt Output (should... (1 Reply)
Discussion started by: pavan.yadalla
1 Replies

6. Shell Programming and Scripting

Copy Column Multiple Times

Hello, I wonder if it my problem can be solved. Inside File1.txt, there are 3 columns. Inside File 2.txt, contain certain variable(in this case, only "3"). So I want to : (copy File 1 x Variable in File 2). Expected result are File 3.txt. Any help are really appreciated. File 1.txt -92.033... (4 Replies)
Discussion started by: guns
4 Replies

7. Shell Programming and Scripting

.sh file To rename existing file and copy new file

Hi All, I am very new to shell scripting . In my current task i want to create .sh file that will rename the existing file with appending _bu in it. And then copy new file . e.g if i have file then i want to rename it to ..Then want replace with latest... (1 Reply)
Discussion started by: maheshkaranjkar
1 Replies

8. Shell Programming and Scripting

copy and rename file..

hi all, I have one config folder and updates folder.updates folder contains file tmp_2.0_20201208_45.xml and config folder contains file tmp.xml.When the tmp_2.0_20201208_45.xml file is copied in the config folder the name of this file is changed in config folder again as tmp.xml(old... (8 Replies)
Discussion started by: shubhig15
8 Replies

9. AIX

How to remove first 5000 lines from file?

Hi I have AIX 5.3 I want schedule a cronjob that can remove first 5000 lines every weekend. Is anybody know the commmand to remove first 5000 lines from unix file? Any Help will be Greatly appreciated. Thanks, Vishal (5 Replies)
Discussion started by: vishalpatel03
5 Replies

10. Shell Programming and Scripting

copy/rename file as date() unix/shell

File.jpg I want to copy and rename this as 2008-12-02.jpg I tried this copy File.jpg date '%y-%m-%d-%H:%M:%S'.jpg This doesnt work.... what do i do? (1 Reply)
Discussion started by: hdogg
1 Replies
Login or Register to Ask a Question