Sorry disturb you again. This one I really stuck because I need to build a lot of fields. What I can do is only build the first field. Others filed gonna blur. What I try to do is matching them first; I=r, I=e, I=a, I=d, B=i, I=n and I=g. After that, get the value before and after r,e,a,d,i,n,g and put them in the right position. If no value put sign "#". Field 7th is in the complete word for "reading" in this case.
Input file:
r e a d i n g<TAB>I I I I B I I
u n l i k e l y<TAB>I E I I I I B I
The expected output is:
I # # # # # # r e a d i n g //'r' is the main character, before 'r' is null and after 'r' are e,a,d,i,n,g
I # # # # # r e a d i n g # //'e' is the main character, before 'e' is r and after 'e' are a,d,i,n,g
I # # # # r e a d i n g # # //'a' is the main character, before 'a' are r,e and after 'a' are d,i,n,g
I # # # r e a d i n g # # # //'d' is the main character, before 'd' are r,e,a and after 'd' are i,n,g
B # # r e a d i n g # # # # //'i' is the main character, before 'i' are r,e,a,d and after 'i' are n,g
I # r e a d i n g # # # # # //'n' is the main character, before 'n' are r,e,a,d,i and after 'n' is g
I r e a d i n g # # # # # # //'g' is the main character, before 'g' are r,e,a,d,i,n and after 'g' is null
This is my trying code and how to loop for the next field?
awk '
{
for (i=1; i<=length($1); i++) print "#"
for (j=1; j<=1; j++) print substr ($1, j, 1)
print ""
}
' $1
The output that I have got:
#
#
#
#
#
#
#
r
#
#
#
#
#
#
#
#
u
Please guide me, Thanks