Awk script:
extract_pat_space.awk
conteúdo:
$0 ~ "^#" pat{ f = 1; hash = 0 }
f { print }
NF == 1 && $1 == "#"{
if (++hash == 2) { f = hash = 0 }
}
Uso (para ambos os padrões):
$ awk -f extract_pat_space.awk -v pat="List" file > list_of_objects.txt
$ awk -f extract_pat_space.awk -v pat="Reports" file > reports.txt
Resultados:
$ cat list_of_objects.txt
#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
#
$ cat reports.txt
#Reports
#
Error-Number 123
Error Number 12345
#