alguns python: warning, eu sou muito novo nisso.
import io
import datetime
buffer = io.StringIO()
ago = datetime.date.today() - datetime.timedelta(days=30)
filename = "file"
with open(filename,"r") as f:
line = f.readline()
while line:
if line.startswith("#"):
date = (line.split())[1]
if date >= ago.isoformat():
buffer.write(line)
line = f.readline()
buffer.write(line)
line = f.readline()
with open(filename, "w") as f:
f.write(buffer.getvalue())