Looping over a range in bash

I don’t know why I always forget how to do ranges, but I do. I guess it has something to do with the fact that I don’t expect it to be like C at all, and I don’t need to use it often enough to remember. I always assume it to be some oddball syntax like x in range 2..6 or something.

Do this:

for ((x=2;x<=6;x++)); do echo $x; done

And the output will be:

2
3
4
5
6
Posted by admica   @   7 April 2009
Tags : , , , , , ,

Related Posts

Like this post? Share it!

Digg Twitter StumbleUpon Delicious Technorati Facebook RSS

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

Name

Email

Website

Previous Post
« Kernel panic after sysctl changes for Oracle
Next Post
How to remove yum packages without dependencies »
Powered by Wordpress   |   Lunated designed by ZenVerse