I have a log file with many instances of statements as shown below:
14 Aug 19 16:30:11.506: <DATA> |POS|IDLE|1|01131844090|5950|$hostIp|$size |$data
20 Aug 19 16:30:12.439: <DATA> |POS|IDLE|1|01131844090|5950|$hostIp|$size |$data
21 ###############################################################################
I want to replace IDLE
just preceding the #########..
to say, END
and have other cases of IDLE
retained.
How do I achieve it?
Edit: Maybe something is different with my actual file. Answers to this question haven't met the requirement. Detailed extract and my requirement is shown below:
22 Aug 19 16:47:33.159: <DATA> |POS|RINGING|1|1126710938|5950|$hostIp|$size |$data
23 Aug 19 16:47:33.453: <DATA> |POS|INIT|1|1126710938|5950|$hostIp|$size |$data
24 Aug 19 16:47:33.484: <DATA> |POS|TRAINING|1|1126710938|5950|$hostIp|$size |$data
25 Aug 19 16:48:05.824: <DATA> |POS|IDLE|1|1126710938|5950|$hostIp|$size |$data
26 Aug 19 16:48:05.916: <DATA> |POS|INIT|1|1126710938|5950|$hostIp|$size |$data
27 Aug 19 16:48:05.947: <DATA> |POS|IDLE|1|1126710938|5950|$hostIp|$size |$data
28 Aug 19 16:48:23.792: <DATA> |POS|IDLE|1|1126710938|5950|$hostIp|$size |$data
29 Aug 19 16:48:23.853: <DATA> |POS|INIT|1|1126710938|5950|$hostIp|$size |$data
30 Aug 19 16:48:23.884: <DATA> |POS|IDLE|1|1126710938|5950|$hostIp|$size |$data
31 ##############################################################################
After operating on the above instance, the result should be:
(IDLE
preceding ####
line is changed to END
.Note there are many instances of such events. My actual need is to find time diff between RINGING
and IDLE - aka END)
22 Aug 19 16:47:33.159: <DATA> |POS|RINGING|1|1126710938|5950|$hostIp|$size |$data
23 Aug 19 16:47:33.453: <DATA> |POS|INIT|1|1126710938|5950|$hostIp|$size |$data
24 Aug 19 16:47:33.484: <DATA> |POS|TRAINING|1|1126710938|5950|$hostIp|$size |$data
25 Aug 19 16:48:05.824: <DATA> |POS|IDLE|1|1126710938|5950|$hostIp|$size |$data
26 Aug 19 16:48:05.916: <DATA> |POS|INIT|1|1126710938|5950|$hostIp|$size |$data
27 Aug 19 16:48:05.947: <DATA> |POS|IDLE|1|1126710938|5950|$hostIp|$size |$data
28 Aug 19 16:48:23.792: <DATA> |POS|IDLE|1|1126710938|5950|$hostIp|$size |$data
29 Aug 19 16:48:23.853: <DATA> |POS|INIT|1|1126710938|5950|$hostIp|$size |$data
30 Aug 19 16:48:23.884: <DATA> |POS|END|1|1126710938|5950|$hostIp|$size |$data
31 ##############################################################################