我需要最后一个小时的日期grep。我的文件输出:
[2019-07-15 02:59:01] VERBOSE[1847] asterisk.c: Remote UNIX connection
[2019-07-15 02:59:01] VERBOSE[456] asterisk.c: Remote UNIX connection disconnected
[2019-07-15 02:59:01] VERBOSE[1847] asterisk.c: Remote UNIX connection
[2019-07-15 02:59:01] VERBOSE[458] asterisk.c: Remote UNIX connection disconnected
[2019-07-15 03:43:01] VERBOSE[1847] asterisk.c: Remote UNIX connection
我尝试
var1="/var/log/asterisk/full-date +'%Y%m%d'";
cat $var1 | tr -d '[]'> "/var/log/asterisk/temp-date +'%Y%m%d-%H-%M'";
grep "$(date -d '-1hour' +'%Y-%m-%d %H')" "/var/log/asterisk/temp-date +'%Y%m%d-%H'";
但是我不知道,也许还有其他方法。