When I run awk '/2017-12-05T12:07:33.941Z/{y=1;next}y' file.json
it works as expected, printing everything after the timestamp.
I'm trying to follow the syntax in this Q/A but my syntax isn't expanding right:
awk -v last_log="$last_log" '/{print last_log}/{y=1;next}y' file.txt
Also trying:
awk -v last_log="$last_log" '/$0 ~ last_log/{y=1;next}y' file.txt
Example, given the following input, return all logs after last processed( 2017-12-05T12:07:33.941Z
):
{ "name": "PeriodicWork", "hostname": "myHost", "pid": 12189, "level": 20, "msg": "Executing [CheckFailedTask NodeId=8]", "time": "2017-12-05T10:07:33.941Z", "v": 0 }
{ "name": "PeriodicWork", "hostname": "myHost", "pid": 12188, "level": 50, "msg": "Executing [CheckFailedTask NodeId=8]", "time": "2017-12-05T12:07:33.941Z", "v": 0 }
{ "name": "PeriodicWork", "hostname": "myHost", "pid": 12187, "level": 40, "msg": "Executing [CheckFailedTask NodeId=8]", "time": "2017-12-05T12:57:33.941Z", "v": 0 }
file.json
content? – RomanPerekhrest Dec 05 '17 at 15:27/{print last_log}/
will not expand your variable... use$0 ~ last_log
– Sundeep Dec 05 '17 at 15:27$0 ~ last_log
without the/
s – Sundeep Dec 05 '17 at 15:28/
s how will it expand into the original command I postedawk '/2017-12-05T12:07:33.941Z/{y=1;next}y' file.json
? – Philip Kirkbride Dec 05 '17 at 15:30$0 ~ last_log
will do the regex matching... give us sample input and output so that we can test... if you want proof, checkseq 18 | awk -v r='4' '$0 ~ r{f=2; next} f && f--'
– Sundeep Dec 05 '17 at 15:32