Script to iterate through lines of alarm log file and execute some lines of code if alarm is active for more than one day
<p>I would like to create a script to loop through lines of alarm log file, extract specific field and then save the result in another external file. The extracted information will then be used to execute additional commands.</p>
<p>Here is an example of the log file and the desired o/p:</p>
<blockquote>
<p>2016-09-29 23:40:14 GST;2016-09-29 23:40:14 GST;faultManager:network@ET_AO_L_0165_abcd@eNBEquip@eNBInst@x2Grp-0@x2Access-0_424_02_ET_AO_L_0165_abcd_44159@x2Transp-0|alarm-2632-3-698;</p>
<p>2016-11-01 07:10:51 GST;2016-11-01 07:10:51 GST;faultManager:network@ER_AO_L_4283_abcd@eNBEquip@eNBInst@x2Grp-0@x2Access-0_424_02_ER_AO_L_4283_abcd_10197@x2Transp-0|alarm-2632-3-698;</p>
<p>2016-11-01 07:10:51 GST;2016-11-01 07:10:51 GST;faultManager:network@ER_AO_L_4283_abcd@eNBEquip@eNBInst@x2Grp-0@x2Access-0_424_02_ER_AO_L_4283_abcd_11339@x2Transp-0|alarm-2632-3-698;</p>
<p>2016-11-01 07:10:51 GST;2016-11-01 07:10:51 GST;faultManager:network@ER_AO_L_4283_abcd@eNBEquip@eNBInst@x2Grp-0@x2Access-0_424_02_ER_AO_L_4283_abcd_14179@x2Transp-0|alarm-2632-3-698;</p>
<p>2016-11-01 11:26:58 GST;2016-11-01 11:26:58 GST;faultManager:network@ET_AO_L_0166_abcd@eNBEquip@eNBInst@x2Grp-0@x2Access-0_424_02_ET_AO_L_0166_abcd_14126@x2Transp-0|alarm-2632-3-698;</p>
<p>2016-11-03 10:00:08 GST;2016-11-03 10:00:08 GST;faultManager:network@ET_AO_L_0193_abcd@eNBEquip@eNBInst@x2Grp-0@x2Access-0_424_02_ET_AO_L_0193_abcd_16113@x2Transp-0|alarm-2632-3-698;</p>
</blockquote>
<p>For each line, it should check if the alarm is active for more than one day (compare to current date), if condition is true then extract the name (ex. ET_AO_L_0165_abcd) and direct it to external file.</p>
<p>Expected o/p (remove duplicates):</p>
<blockquote>
<p>ET_AO_L_0165_abcd</p>
<p>ER_AO_L_4283_abcd</p>
<p>ET_AO_L_0166_abcd</p>
<p>ET_AO_L_0193_abcd</p>
</blockquote>
<p>Thanks in advance</p>