LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-23-2006, 04:49 PM   #1
stefaandk
Member
 
Registered: Jun 2005
Distribution: Centos
Posts: 215

Rep: Reputation: 30
Lightbulb 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,
 
Old 03-23-2006, 05:12 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,310
Blog Entries: 54

Rep: Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860
man seq
man xargs
leads to
seq 1 100|xargs -iN cp blank.gif N.gif
 
Old 03-23-2006, 05:13 PM   #3
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 151Reputation: 151
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

Last edited by gilead; 03-23-2006 at 05:14 PM.
 
Old 03-23-2006, 05:21 PM   #4
stefaandk
Member
 
Registered: Jun 2005
Distribution: Centos
Posts: 215

Original Poster
Rep: Reputation: 30
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.
 
Old 03-23-2006, 05:25 PM   #5
stefaandk
Member
 
Registered: Jun 2005
Distribution: Centos
Posts: 215

Original Poster
Rep: Reputation: 30
This one worked btw

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

Thanks for your help guys!
 
Old 03-23-2006, 05:30 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,310
Blog Entries: 54

Rep: Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860Reputation: 2860
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.
 
Old 03-23-2006, 06:20 PM   #7
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GIF help oldstinkyfish Linux - Software 1 12-03-2004 12:49 AM
making .tif files into animated .gif files (bash shell, Red Hat 7.2) illiniguy3043 Linux - Newbie 1 06-01-2004 04:04 PM
converting .tif images to an animated .gif file with a script illiniguy3043 Programming 2 06-01-2004 03:11 PM
converting .tif images to an animated .gif file (Red Hat 7.2, bash shell) illiniguy3043 Linux - General 0 06-01-2004 01:07 PM
no gif raven Linux - General 0 03-16-2002 05:20 AM


All times are GMT -5. The time now is 01:56 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration