Context
I receive a daily bunch of messages from apticron telloing me the servers I need to upgrade.I want to get the list of hostnames needing updates from the las two days.
Recipe
- Get into the Maildir folder
- Get to day and yesterday date
- Grep the Messages for it
cd /home/mihamina/Mail/ export TODAY=$(date +%Y%m%d) export TODAY_STRING=$(date +"%a, %d %b %Y") export YESTERDAY=$(($(date +%Y%m%d)-1)) export YESTERDAY_STRING=$(date +"%a, %d %b %Y" --date=$YESTERDAY) (for MESS in $(grep -E "^Date: (${TODAY_STRING}|${YESTERDAY_STRING})" * \ | awk 'BEGIN{FS=":"}{print $1}'); do grep -E "^Subject: " $MESS | awk 'BEGIN{FS=" on "}{print $2}'; done) | sort | uniq