Search code examples
bashshellunixkshhp-ux

using "for" command in hp unix


The below for doesn't work in hp-ux. However, it works on redhat machine. could please let me know what is incorrect here?

#/bin/ksh
Rowcount=`wc -l $acList | awk -F " " '{print $1}'`

for ((i=1; i<=Rowcount; i++)); do
.
.
.

Error i'm getting is:

 syntax error at line 4 : `(' unexpected

Solution

  • You can use a while loop:

    i=1
    while (( i <= Rowcount ))
    do
       # Your code
       (( i+= 1 ))
    done