insert predefine text in front and on a loop

Hi Experts,

I wish to insert predefined text in front of every line and this needs to be in a loop because it is always expanding.

Before :
11111111
22222222
33333333
44444444

55555555
77777777
88888888
00000000

[...]

To be Inserted :
a=
b=
c=
d=

After :
a=11111111
b=22222222
c=33333333
d=44444444

a=55555555
b=77777777
c=88888888
d=00000000

[...]

I've been searching and trying but to no avail :frowning:

Thank you in advance,
Bata

In a loop:

CHR=(a b c d)
while read LINE; do
  [ -z "$LINE" ] && p=0 && echo && continue
  echo ${CHR[((${p:-0}%4))]}=$LINE
  ((p=p+1))
done < file1

What's always expanding? The input data or the "predefined" text?

If the latter:

awk -v c=97 '
  /^$/ { c=97; print; next }
  { printf "%c %s\n", c++, $0 }
' file1
1 Like

Hi scottn,

It worked! Thank you very much.

What I meant earlier is that the input data is always expanding.

Have a nice day!