Issue
I'm trying to check last 10 hours change in /var/log/messages with following commands (grep and sed). Grep is pulling all the data from last 3 days. Sed is running successfully but no result. Can someone please help me out with these commands or any other commands to check changes in log files.
sed -n "/^$(date '+%b %_d %H:%M' -d -10 hours)/,\$p" /var/log/messages
grep "^$(date +'%Y-%M-%d %H %M' -d -10 hours)" /var/log/messages
Solution
Solved with the following command
awk -v d1="$(date --date="-600 min" "+%b %_d %H:%M")" \
-v d2="$(date "+%b %_d %H:%M")" '$0 > d1 && $0 < d2 ||
$0 ~ d2' /var/log/messages
Thank you very much for your help.
Answered By - mani