1

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
ShravanM
  • 323
  • 1
  • 7
  • 21
  • @fedorqui still the same error `(' unexpected – ShravanM Sep 22 '14 at 09:08
  • I see it is fine either `i<=Rowcount` or `i<=$Rowcount`. What I see is that you could directly do `Rowcount=$(wc -l < $acList)`. Using `< file` avoids the extra space. – fedorqui Sep 22 '14 at 09:25

2 Answers2

0

You can also try this syntax :

#!/bin/ksh
for f in $(wc -l $acList | awk -F " " '{print $1}')
do
        print "blabla : $f"
done
Thomas Ayoub
  • 29,063
  • 15
  • 95
  • 142
  • in my case Rowcount value is 3, i have tried your command but it only prints once. i want a set of operations to be done for 'Rowcount' no of times (here 3). – ShravanM Sep 22 '14 at 09:14
  • @user215827 I see (but don't understand) and I can't test it now, sorry – Thomas Ayoub Sep 22 '14 at 09:18
0

You can use a while loop:

i=1
while (( i <= Rowcount ))
do
   # Your code
   (( i+= 1 ))
done
Juan Diego Godoy Robles
  • 14,447
  • 2
  • 38
  • 52