Help with Creation of Script to Input Separators in Data
Hi all,
I have one problem that is preparing datas so I can run a script to extrat informations for my statistic reports.
I receive some datas, that are informations mixed and I need to separate them to analyse. This is an exemple of datas:
#header: 0MEPS000006000000051620090508001200905070010001613200020090508001
#body: 20421730007384620090507144018000001000000000A000000020283139Somewhere 00000001600
#body: 20421730007414520090507144237000001000000000A000000020283148Somewhere 00000001700
#body: .
#body: .
#body: .
#body: .
#body: .
#body: .
#tail: 9000000020000000000020000000000000000000000000000
Note that this #body, header does not include in this data.
So I receive them like this, but I need them to be like this:
0,MEPS,00000600,00000516,20090526001,20090525001,00016,132,000,20090526001,
2,04,2191,00112407,20090525233138,0000200000,00000,A,0000000502,98032,Somewhere ,020000008,0,0,
2,04,2191,00008894,20090525075812,0000010000,00000,A,0000001301,55245,Somewhere ,100000147,0,0,
.
.
.
.
9,00000059,0000000001790000,000000000000,000000000000,
So in this manner I can run my script:
#!/bin/bash
echo "
serial_nb amount date time ATM_nb location"
awk -F, '$1==2 {print$13,$7,$5,$6,$10,$12}' file_name
which produce me the results I want:
serial_nb amount date time ATM_nb location
000000016 0000010000 20090507 144018 0000000202 Somewhere
000000017 0000010000 20090507 144237 0000000202 Somewhere
So, right now I prepare my datas with the aid of excell, but I rather use an awk command to to this.
I need a command that says: input "," after 2 characters, then input another one after 5, etc etc.
Bottom line, a command that inputs separators acording to lenght.
Thanks for all your help.