The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


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

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 iBot Oracle Updates (RSS) 0 04-06-2008 02:10 AM
while loop inside while loop panknil Shell Programming and Scripting 0 01-07-2008 08:49 AM
simplifying awk sil Shell Programming and Scripting 1 09-21-2006 10:47 AM
Help in simplifying a sed command wvdeijk Shell Programming and Scripting 3 03-04-2005 03:39 AM
how to get the similar function in while loop or for loop trynew Shell Programming and Scripting 3 06-17-2002 08:09 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-15-2006
Registered User
 

Join Date: Jul 2006
Posts: 13
Stumble this Post!
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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-15-2006
Registered User
 

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

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,241
Stumble this Post!
If bash...
Code:
for ((x=1; x<=10; x++))
do
     echo $x
done
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:12 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0