How to get all the log lines between two dates ranges in Linux? I tried certain commands like
1)awk '$0>=from&&$0<=to' from=\"Wed 21 Mar 14:52:08\" to=\"Wed21 Mar
14:53:08\" /home/db2inst1/logs/tracestart.log
but it gives me only those lines which has those exact dates in them.
2) sed -n '/Wed 21 Mar 14:52:00/,/Wed 21 Mar 14:53:08/p'
/home/db2inst1/logs/tracestart.log /home/db2inst1/logs/traceend.log
This one gives me correct data but date(Wed 21 Mar 14:52:00)
should be an exact match, otherwise there is no output for nearest time also. For example, if Wed 21 Mar 14:52:01
is the start time then there is also no output.
log file sample::
2018-04-04 11:40:46 INFO RestAssuredService:184 - some thing.......
2018-04-04 11:40:48 INFO RestAssuredService:199 - some thing.......
2018-04-04 11:40:48 INFO RestAssuredService:177 -
*********invokeService is
2018-04-04 11:40:48 INFO ProductInfoTest:57 - Response Map:::::
{RESPONSE_TYPE=application/json, EXPECTED_RESPONSE={
"products": [
{
"id": 23001,
"type": "SHIRT",
"description": "Mens Wear Dresses",
"price": 850,
"brand": "PETER_ENGLAND"
},
{
"id": 23002,
"type": "KURTI",
"description": "Womens Wear Dresses",
"price": 899,
"brand": "ALLEND_SOLEY"
}
] },
ACTUAL_RESPONSE=com.jayway.restassured.internal.RestAssuredResponseImpl@7d48651a}
2018-04-04 11:40:48 INFO ProductValidator:47 - EXPECTED_RESPONSE:::: {
"products": [
{
"id": 23001,
"type": "SHIRT",
"description": "Mens Wear Dresses",
"price": 850,
"brand": "PETER_ENGLAND"
},
{
"id": 23002,
"type": "KURTI",
"description": "Womens Wear Dresses",
"price": 899,
"brand": "ALLEND_SOLEY"
}
] }
2018-04-04 11:40:48 ERROR ProductInfoTest:65 - Exception occured::: null
2018-04-04 11:40:48 INFO ProductInfoStepDefinations:27 - addProductDetailsApiTest Starting::::
2018-04-04 11:40:48 INFO ProductInfoTest:53 - getAllProductsInfo starting
2018-04-04 11:40:48 INFO RestAssuredService:170 -
*********invokeService is starting*********
2018-04-04 11:40:48 INFO RestAssuredService:247 - Final uri:::::: rest/market/item/info
2018-04-04 11:40:48 INFO RestAssuredService:258 - HeaderParametersMap :::::: {Accept=application/json, Content-Type=application/json