While Loop issue

Hi,

i=0
t5=6000001
while [ $i -lt 100 ]
do

i=`expr $i + 1`
t5=`expr $t5 + 1`
echo $t5
done 

I am able to increment "col3" value but unable to get col1,col2 value.

Input:

t1=10001
t2=abc
t3=ghkc
t4=cbf
t5=6000001

output

col1,col2,col3,col4,col5,col6
10001,abc,6000001,,,,,,,
10001,ghkc,6000002,,,,,,,
10001,cbf,6000003,,,,,,,
10002,abc,6000004,,,,,,,
10002,ghkc,6000005,,,,,,,
10002,cbf,6000006,,,,,,,
10003,abc,6000007,,,,,,,
10003,ghkc,6000007,,,,,,,
10003,cbf,6000008,,,,,,,

Thanks
onesuri

Use codetag for data as well, after 73 posts don't you know that you have to use codetag for data as well as for code. and you have given input and output, could you please explain their relationship.

This is bash-only. t234 is an array, first element is t234[0] to be referenced as ${t234[0]}
The indices 0 1 2 0 1 2 ... are achieved by i%3 (modulo 3)

#/bin/bash
i=0
t1=10001
t234=(abc ghkc cbf)
t5=60000001
while [ $i -lt 100 ]; do
  echo $((t1+i/3)),${t234[$((i%3))]},$((t5+i)),,,
  ((i++))
done

without more specifications

d=6000000;for i in  100{1..3},{abc,ghkc,cbf} ; do printf '%s,%s\n' "$i" $((d++)); done
1001,abc,6000000
1001,ghkc,6000001
1001,cbf,6000002
1002,abc,6000003
1002,ghkc,6000004
1002,cbf,6000005
1003,abc,6000006
1003,ghkc,6000007
1003,cbf,6000008
1 Like

Interesting solution!
The loop is only needed for col#3, the rest could be done with

printf "%s\n" 1000{1..3},{abc,ghkc,cbf},

Generic shell (POSIX):

t1=10001
t2="abc ghkc cbf"
t5=6000001
i=0
while :
do
  for j in $t2
  do
    if [ $((i+=1)) -gt 100 ]; then
      break 2
    fi
    printf "%s,%s,%s,,,,,,,\n" "$t1" "$j" "$t5"
    t5=$(( t5 + 1 ))
  done
  t1=$(( t1 + 1 ))
done