I have a log and I want to print all the lines from the log between two dates 02/04/2015:14:23:00
and 02/04/2015:14:23:59
相关问题
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- JQ: Select when attribute value exists in a bash a
- Error building gcc 4.8.3 from source: libstdc++.so
- Why should we check WIFEXITED after wait in order
Another approach with a sed one-liner:
sed -n '/start/,/end/p' log.txt
Please note it will not work as expected if start and end tokens are in the same line.
This case is very simple - use grep and match
02/04/2015:14:23:
:General/universal case is more complicated. You have to find first and last line, and then print lines.
To find first and last line, use something like this (dates only for example):
Command greps all lines matching some pattern, than selects first/last matching line, and cuts the line number from it.
This can be used with
tail
andhead
to select matching lines:Following script summarize the operations: