I have a file with 500+ lines. This file consists output of 3 server details separated by "---------" symbol with 5 categories.
For ex: I have a file named Test.txt in my Linux server
Contents of the file as follows.
########
Server 1
########
--------
Category 1
No issue
--------
Category 2
XYZ File system is 90%
--------
Category 3
ABC codes are deployed
--------
Category 4
No issue
--------
Category 5
AB123 user is added
--------
########
Server 2
########
--------
Category 1
Backup is completed
--------
Category 2
XYZ File system is 90%
--------
Category 3
ABC codes are deployed
--------
Category 4
No issue
--------
Category 5
AB123 user is added
DD444 user is deleted
--------
########
Server 3
########
--------
Category 1
No issue
--------
Category 2
XYZ File system is 90%
ABC File system is 95%
--------
Category 3
ABC codes are deployed
DEF codes are deployed
--------
Category 4
No issue
--------
Category 5
AB123 user is added
CD456 user is added
EF789 user is added
AD111 user is added
BB222 user is deleted
--------
Here i expect the output to be copied into new file by ignoring the No issue categories.
Expected output:
########
Server 1
########
--------
Category 2
XYZ File system is 90%
--------
Category 3
ABC codes are deployed
--------
Category 5
AB123 user is added
--------
########
Server 2
########
--------
Category 1
Backup is completed
--------
Category 2
XYZ File system is 90%
--------
Category 3
ABC codes are deployed
--------
Category 5
AB123 user is added
DD444 user is deleted
--------
########
Server 3
########
--------
Category 2
XYZ File system is 90%
ABC File system is 95%
--------
Category 3
ABC codes are deployed
DEF codes are deployed
--------
Category 5
AB123 user is added
CD456 user is added
EF789 user is added
AD111 user is added
BB222 user is deleted
--------
Since i am new to Unix scripting, i can barely achieve the output.
i tried below sed and awk commands but i did not succeed.
sed -n '/^------/,/^------/p, Test.txt -> But the output is missing some categories between "------" symbol
awk -v RS="------" '$0~/No/{print $0 RS}' Test.txt -> Getting symbol error
Can someone please help me achieve the desired output.
Thanks in advance.