Get the log line with date range

If you want to extract log with prefix is date time like this

[2017-05-01 02:00:06,300] this is a log line details

We might use the awk command following with the condition

awk -F'[]]|[[]'   '$0 ~ /^\[/ && $2 >= "2017-05-01 00:00" { p=1 } $0 ~ /^\[/ && $2 >= "2017-06-01 00:00" { p=0 } p { print $0 }' details.log >  2017-05.log

 

 

Bình luận về bài viết này