Range specification in for loop

Hello Friends,

I want to use range in for loop. For that i used (..) operator but it is not working.

Ex:
for i in 1..24
do
echo $i
done

Instead of printing 1 to 24 nos, it gives o/p as: 1..24

Please help me

Thanks in advance.

Your shell does not have the .. range operator. Try this instead:

#!/bin/bash
LIMIT=24
for ((a=1; a <= LIMIT ; a++))  # Double parentheses, and "LIMIT" with no "$".
do
  echo -n "$a "
done                           # A construct borrowed from 'ksh93'.
echo; echo

or this:

#!/bin/bash
NUMBERS="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24"
for number in `echo $NUMBERS`  # would be similar to: for number in 1 .. 24
do
  echo -n "$number "
done
echo 

using Perl:

#!/usr/bin/perl
for $i (1 .. 24) {
    print $i, "\n";
}

Perl one liner:

perl -e 'for $i (1 .. 24) { print $i, "\n"; }'