Following Input File:
#Report Nr. 2343215
#Errors 3243
#Date: (Timestampt)
#Informaiton
#
# Headers
# Specs
DLSLWD 0 0 0 0 Jun 22 01:51:16PM 2018
#List of Objects
#
# Headers
# Paths
Files not found /var/xxxxx
Files not found /etc/xxxxx
Files not found /mnt/xxxxx
Files not found /safd/xxxxx
#
#Reports
#
Error-Number 123
Error Number 12345
#
What i need is an awk that pipes the "List of Objects" into a new file:
#List of Objects
#
# Headers
# Paths
Files not found /var/xxxxx
Files not found /etc/xxxxx
Files not found /mnt/xxxxx
Files not found /safd/xxxxx
#
And the " Reports"into a differnt file:
#Reports
#
Error-Number 123
Error Number 12345
#
It's a match for #List of Objects + 3 lines until "first" #.
Same for the Reports: Match #Reports + 1 line until "first" #.
At first i tried something like:
awk '/#List of Objects/,/#Reports/'
For the list of objects followed by:
awk '/#Reports/,0'
To get the data from #Reports until EOF.
But because #Reports and #List of Objects are both OPTIONAL and not in every input file I can't use #Reports as the "END-Pattern". so, I have to match on the # but ignore the first X occurrences of # after the matching pattern.