openSUSE Forums > Archives > SF Archives > ARCHIVES - Programming & Scripting » Tacking Together Text And Incrementing Integers

Go Back   openSUSE Forums > Archives > SF Archives > ARCHIVES - Programming & Scripting
Forums FAQ Members List Search Today's Posts Mark Forums Read


ARCHIVES - Programming & Scripting A place to discuss website design, programming, shell scripts, etc

 
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-Jun-2008, 04:39
Roland Deschain
Guest
 
Posts: n/a
Default

I've got a simple script going that parses through looking for files in a certain range of numbers and grabs them with wget, but I'm stuck on one thing. Here's what I need:

I've got two strings, one is a prefix "wget http://website.com/images/image0" and the other is a suffix, ".jpg". I want to sandwich between those two an integer that increments. I've got the loop going fine, I just don't know how to get it to stick together and become a single command inside the loop.

I did know how to do this in Java back in the day, but I'll be buggered if I can get this to work
  #2 (permalink)  
Old 01-Jun-2008, 05:00
ken_yap
Guest
 
Posts: n/a
Default

wget http://website.com/images/image${i}.jpg
  #3 (permalink)  
Old 01-Jun-2008, 07:29
Roland Deschain
Guest
 
Posts: n/a
Default

Worked a charm, thanks.
  #4 (permalink)  
Old 01-Jun-2008, 07:36
ken_yap
Guest
 
Posts: n/a
Default

If your integers have to be a certain width, then use printf.

wget http://website.com/images/image$(printf "%02d" $i).jpg

The $() construct is bash specific though. If you want to be portable to sh, then use backticks ``.
 

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2