LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   need shell script to copy 1.gif to 1-100.gif (http://www.linuxquestions.org/questions/programming-9/need-shell-script-to-copy-1-gif-to-1-100-gif-427803/)

stefaandk 03-23-2006 04:49 PM

need shell script to copy 1.gif to 1-100.gif
 
Need to copy a blank .gif file called 1.gif to 1.gif, 2.gif, 3.gif etc up to a 100.gif.

Could someone provide me with a script to achieve that as I really don't want to do it manually.

Thanks,

unSpawn 03-23-2006 05:12 PM

man seq
man xargs
leads to
seq 1 100|xargs -iN cp blank.gif N.gif

gilead 03-23-2006 05:13 PM

Does the following do what you want?
Code:

#!/bin/bash

for i in $(seq -w 2 100);  do
  cp 1.gif $i.gif
done

-- I'm having a run on posting too slowly today ;)

stefaandk 03-23-2006 05:21 PM

Almost there but it actually makes em 001.gif, 002.gif

I don't want the zeroes in front of em cause the links wouldn't work.

Thanks.

stefaandk 03-23-2006 05:25 PM

This one worked btw

seq 1 100|xargs -iN cp blank.gif N.gif

Thanks for your help guys!

unSpawn 03-23-2006 05:30 PM

I don't want the zeroes in front of em
If you read man seq you see that's because of -w (equal width).


I'm having a run on posting too slowly today
Quality counts, speed doesn't IMHO.

chrism01 03-23-2006 06:20 PM

eg:
for i in `seq 1 10`; do cp t.gif $i.gif; done


All times are GMT -5. The time now is 09:04 AM.