I'm trying to extract XML entities with a given time attribute in a large file:
<afs>
<af timestamp="Jun 30 09:11:58 2015">
...
</af>
<af timestamp="Jun 30 09:13:20 2015">
....
</af>
</afs>
I get all the blocks with this script in bash/sed but I can't find any good approach to do it with Python.
m1=`date '+%b %d %H:%M' -d "-1min"`
m2=`date '+%b %d %H:%M' -d "-2min"`
sed -n "/^<af .*\($m1\|$m2)/,/^<\/af>/p" $LOG
I can't use ElementTree due to an OS limitation to Python 2.4.3 Thanks in advance.