Need you your help with the following awk syntax. Below is the output from my curl and I need to refine it a little bit:
INPUT:
RSYNCA-BACKUP
RCYNCA 20140517 0021 2182097 2082097
2014820905820917 10:03:54
2014820905820917 10:37:43
0:33:49
RSYNCB-COPY
20140517 0020 2082097 1982097 7 6 20
2014820905820917 09:32:20
2014820905820917 10:59:20
1:27:00
RSYNCC
RCYNCE 20140517 0021 2182097 2082097
2014820905820917 10:03:54
2014820905820917 10:37:43
0:33:49
RSYNCD
20140517 0020 2082097 1982097 7 6 20
2014820905820917 09:32:20
2014820905820917 10:59:20
1:27:00
THE OUTPUT I RECEIVE USING AWK:
RSYNCA-BACKUP|20140502|RCYNCA|10:02:15|10:56:42|0:54:27|FINISHED
RSYNCB-COPY|0022||15:31:06| |0:06:04|INITIATED
Job Name|sequence|date|start time|end time|runtime|status
For job with initiated status there is no end time so the field can be empty
Thats what I am running and getting messed up awk output
awk -v RS='FINISHED|INITIATED' -v OFS='|' '$0 { print $1, $3, $2, $8, RS }'
RSYNCJOBNA|0021|20140502|2014820905820902|FINISHED|INITIATED
RSYNCJOBNA|0022|20140502|2014820905820902|FINISHED|INITIATED
My input from curl has additional spaces I guess, that might be the issue, here is a real example:
INITIATED
RSYNCA
20140502 0036 3682096 3582096 6 5
2014820905820902 17:31:08
0:17:16 ce eque
INITIATED
RSYNCA
20140502 0035 3582096 3482096 6 5
2014820905820902 17:01:10
0:47:14 ce eque
FINISHED
RSYNCA
20140502 0034 3482096 3382096 6 5
2014820905820902 16:31:03
2014820905820902 17:24:45
0:53:42
FINISHED
RSYNCA
20140502 0033 3382096 3282096 6 5
2014820905820902 16:01:09
2014820905820902 16:47:12
0:46:03