rudic:
Try
awk '
{gsub (/[^0-9;]/, _)
$3 = substr ($3, 1, length ($3) - 1)
}
$3 != LAST {print "Time: " $3
print "Item_Nu;xw;tr;vyy;ANf;Gk;kl"
LAST = $3
}
{print $4, $5, $6, $7, $8, $9, $10
}
' FS=";" OFS=";" file
Time: 101500
Item_Nu;xw;tr;vyy;ANf;Gk;kl
1010;129;54;87;876;67;888
1020;129;54;87;876;67;888
1030;129;54;87;876;67;888
1040;129;54;87;876;67;888
Time: 103000
Item_Nu;xw;tr;vyy;ANf;Gk;kl
1010;134;54;87;845;63;882
1020;169;34;87;576;62;883
1030;179;24;87;676;62;884
1040;189;94;87;764;63;885
Time: 104500
Item_Nu;xw;tr;vyy;ANf;Gk;kl
1010;109;84;87;976;67;888
1020;129;74;87;776;67;888
1030;139;64;87;876;67;888
1040;125;54;87;876;67;888
Thank you so much for help.Once I tried it in the relay file I failed to edit it because I'm still learning . here sample of the real logs, also it removed the comma in the last five tags LMc ,LMv,LMg,RMv and RMg.
PEr;n534385;i123;Si4300;s1;PSt123000;PSp124500;EOdN;WAs0.05;RWa0.9852;WBb5.05;WBa5.1;WVq5.0596;BWs5.3088;BWb4.9765;TVs14650389.4344;TVb10501152.6287;BAv1088536.2633;BAu5551534.9429;NBa19.0832;AAv14650389.4344;AAu77776460.6215;ABa1047.6402;BBv4555746.6461;BBu23006520.5626;NBb215.3979;ABv10501152.6287;ABu52259658.6045;ABb587.6587;BMv2822141.4547;BMu14279027.7528;NBm117.2406;AMv12575771.0315;AMu65018059.613;ABm817.6495;OCt100;OCb100;OCa100;BAb76.0958;BAa-28.3254;CIb43.387;CIa7.4302;LMc5000,25000,50000,100000,250000,500000,750000,1000000,2000000,3000000;LMv99,99,99,99,99,99,99,99,99,99;LMg100,100,100,100,100,100,100,100,100,100;RMc5000,25000,50000,100000,250000,500000,750000,1000000,2000000,3000000;RMv99,99,99,99,99,99,99,99,99,99;RMg100,100,100,100,100,100,100,100,100,100;
---------- Post updated at 05:51 AM ---------- Previous update was at 05:50 AM ----------
ravindersingh13:
Hello abdul2020,
If you are not worried about the sequence of the time values then following may help you in same too.
awk -F"[;|,]" '{gsub(/[[:alpha:]]/,X,$0);Q=$3;gsub(/.*s1|^;/,X,$0);A[Q]=A[Q]?A[Q] ORS $0:$0;}END{for(i in A){print "Time" i ORS "Item_Nu;xw;tr;vyy;ANf;Gk;kl" ORS A}}' Input_file
Output will be as follows.
Time101500
Item_Nu;xw;tr;vyy;ANf;Gk;kl
100000;101500,1;1010;129;54;87;876;67;888
100000;101500,1;1020;129;54;87;876;67;888
100000;101500,1;1030;129;54;87;876;67;888
100000;101500,1;1040;129;54;87;876;67;888
Time104500
Item_Nu;xw;tr;vyy;ANf;Gk;kl
103000;104500,1;1010;109;84;87;976;67;888
103000;104500,1;1020;129;74;87;776;67;888
103000;104500,1;1030;139;64;87;876;67;888
103000;104500,1;1040;125;54;87;876;67;888
Time103000
Item_Nu;xw;tr;vyy;ANf;Gk;kl
101500;103000,1;1010;134;54;87;845;63;882
101500;103000,1;1020;169;34;87;576;62;883
101500;103000,1;1030;179;24;87;676;62;884
101500;103000,1;1040;189;94;87;764;63;885
EDIT: Adding a non one-liner form for solution on same.
awk -F"[;|,]" '{
gsub(/[[:alpha:]]/,X,$0);
Q=$3;
gsub(/.*s1|^;/,X,$0);
A[Q]=A[Q]?A[Q] ORS $0:$0;
}
END{
for(i in A){
print "Time" i ORS "Item_Nu;xw;tr;vyy;ANf;Gk;kl" ORS A
}
}
' Input_file
Thanks,
R. Singh
Thanks for help, the time sequence is important