Issue
I want to select lines between two timestamps - 60 minutes before and now
My command is
sed -n '/"$(date -d '60 minutes ago' +"%H:%m")"/,/"$(date -d +"%H:%m")"/p' /var/www/html/glpi/files/_log/event.log/
But i get :
sed: -e expression #1, char 14: unterminated address regex
Solution
In single quotes, $(
and "
are not treated specially, and single quotes don't nest.
You also probably don't want to use the %H:%m
format, as it means hour:month
.
sed -n "/$(date -d 60\ minutes\ ago +%H:%M)/,\$p"
But if the exact time wasn't logged, it wouldn't work. It might be better to use a more powerful language than sed
that can actually parse the timestamps and compare them properly.
Answered By - choroba Answer Checked By - Terry (WPSolving Volunteer)