Lets say I have an input file like this:
#Backup TOC
boot.tar.gz /boot/
#Filesystems
/boot /dev/mapper/VolGroup-lv_root xfs
#Devices
/dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:0:0-part1 PHY /dev/disk/by-path/pci-0000:03:00.0-scsi-0:0:0:0
#UnhandledFS
/var/
/var/log
/var/log/audit
/var/tmp
I want to extract content between every #header (and the last #UnhandledFS can be ignored), once extracted I have to check whether there is any entry available or not.
Below code I use to extract content between two #header. But it is however not repeating
lines = open("./input").readlines()
re.compile('#\w+(.*?)#\w+', re.DOTALL | re.M).findall(''.join(lines))