0

I am trying to implement the following nested for loop-

for(int i=2000;i<=2013;i++)
  for (int j=i+1;j<=2014;j++)
   {
     }

I tried the following

for i in {2000..2013}
 do
  for j in {$((i+1))..2014}
   do
   done
 done

but it's not working. Anybody can help. please.

sovon
  • 877
  • 2
  • 12
  • 28

1 Answers1

1

Bash has syntax for C-like loops.

for ((i=2000;i<=2013;i++)); do
  for ((j=i+1;j<=2014;j++)); do
    : stuff
  done
done

This is not portable to other shells (notably sh / dash).

tripleee
  • 175,061
  • 34
  • 275
  • 318