Created
December 17, 2014 12:40
-
-
Save laszlomiklosik/a17956506e86058af095 to your computer and use it in GitHub Desktop.
Cropping the relevant section from a log file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1) get line number of first relevant log line: (e.g. by date 2014-01-13 13:49) | |
grep "2014-01-13 13:49" original.log -n | more | |
# 2) get line number of last relevant log line: (e.g. by date 2014-01-13 16:36) | |
grep "2014-01-13 16:36" original.log -n | more | |
# 3) the total number of lines from the original log file: | |
wc -l original.log -n | |
# e.g. results of 1-3: | |
# - from: 2148520 | |
# - to: 3621984 | |
# - length: 3666691 | |
# 4) create the cropped file using a command similar to | |
# head -n (TO) orig.log | tail -n (TO-FROM) | |
# in our concrete example: | |
head -n 3621984 orig.log | tail -n 1473464 > relevant_only.log | |
# (if you need to use it frequently script all this)! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment