Hi,
I'm trying to filter the following output to only display information about an alarm where the Status: corresponds to Set.
--------------------------------------------------------
Description: hw_optics: RX POWER LANE-0 LOW ALARM
Location: Optics0/0/0/21
AID: XR/HW_OPTICS/45
Tag String: DEV_SFP_OPTICS_PORT_RX_POWER_LOW_ALARM_LANE0
Module Name: Optics0/0/0/21
EID: PORT/OPTICS/21
Reporting Agent ID: 196678
Pending Sync: false
Severity: Major
Status: Clear
Group: Software
Set Time: 06/19/2019 05:01:23 UTC
Clear Time: 06/19/2019 23:54:24 UTC
Service Affecting: NotServiceAffecting
Transport Direction: NotSpecified
Transport Source: NotSpecified
Interface: N/A
Alarm Name: OPTICS RX POWER LANE-0 LOW ALARM
--------------------------------------------------------
Description: hw_optics: RX POWER LANE-0 LOW WARNING
Location: Optics0/0/0/21
AID: XR/HW_OPTICS/53
Tag String: DEV_SFP_OPTICS_PORT_RX_POWER_LOW_WARNING_LANE0
Module Name: Optics0/0/0/21
EID: PORT/OPTICS/21
Reporting Agent ID: 196678
Pending Sync: false
Severity: Minor
Status: Set
Group: Software
Set Time: 06/19/2019 05:01:23 UTC
Clear Time: 06/19/2019 23:54:24 UTC
Service Affecting: NotServiceAffecting
Transport Direction: NotSpecified
Transport Source: NotSpecified
Interface: N/A
Alarm Name: OPTICS RX POWER LANE-0 LOW WARNING
--------------------------------------------------------
Expected output
--------------------------------------------------------
Description: hw_optics: RX POWER LANE-0 LOW WARNING
Location: Optics0/0/0/21
AID: XR/HW_OPTICS/53
Tag String: DEV_SFP_OPTICS_PORT_RX_POWER_LOW_WARNING_LANE0
Module Name: Optics0/0/0/21
EID: PORT/OPTICS/21
Reporting Agent ID: 196678
Pending Sync: false
Severity: Minor
Status: Set
Group: Software
Set Time: 06/19/2019 05:01:23 UTC
Clear Time: 06/19/2019 23:54:24 UTC
Service Affecting: NotServiceAffecting
Transport Direction: NotSpecified
Transport Source: NotSpecified
Interface: N/A
Alarm Name: OPTICS RX POWER LANE-0 LOW WARNING
--------------------------------------------------------
I've tried the following code but it doesn't work.
grep -P -B 10 -A 9 'Status:(.*Clear)' alarms.txt <--- prints out the block with "Clear"
$ grep -P -B 10 -A 9 'Status:\!(.*Clear)' alarms.txt <--- does not print anything
Can I get some assistance around this?
*****************************************************************************************************************************
Just realised that the host machine does not support "grep -P" option.
Is there any alternative to accomplish this?
*****************************************************************************************************************************
Thanks.