Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-15-2006
Registered User
 

Join Date: Jul 2006
Posts: 13
Simplifying the For loop

Is there a way to simplify stating 1 through to 10, for example in a for loop construct?

for x in 1 2 3 4 5 6 7 8 9 10
do
....
done

I have tried [1-10] (1-10) with no luck.. thanks
Sponsored Links
  #2 (permalink)  
Old 07-15-2006
Registered User
 

Join Date: Jul 2006
Posts: 1
In bash I presume. Ty this:
i=0
while [ $i -lt 10 ]
do
echo $i
let "i++"
done
  #3 (permalink)  
Old 07-15-2006
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,431
If bash...
Code:

for ((x=1; x<=10; x++))
do
     echo $x
done

Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Simplifying Web Services Development with the Decorator Pattern Linux Bot Oracle Updates (RSS) 0 04-06-2008 06:10 AM
while loop inside while loop panknil Shell Programming and Scripting 0 01-07-2008 12:49 PM
simplifying awk sil Shell Programming and Scripting 1 09-21-2006 02:47 PM
Help in simplifying a sed command wvdeijk Shell Programming and Scripting 3 03-04-2005 07:39 AM
how to get the similar function in while loop or for loop trynew Shell Programming and Scripting 3 06-17-2002 12:09 PM



All times are GMT -4. The time now is 06:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0