Created
January 23, 2013 12:14
-
-
Save adamatan/4604933 to your computer and use it in GitHub Desktop.
AWK: Extract text between two delimiters. Write each match to 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
| # First thread dump line | |
| /^Full thread dump Java/ { | |
| thread_dump=1; | |
| counter++; | |
| lines=0; | |
| filename="Thread_dump_"counter".txt"; | |
| printf "Found thread dump #%-4d\t", counter | |
| } | |
| # Last thread dump text block | |
| /^Heap[:space:]*$/ { | |
| thread_dump=2; | |
| } | |
| # Last thread dump line - first blank line after "Heap" | |
| { if (thread_dump==2 && $0 ~ "^[:space:]*$") { | |
| thread_dump=0; | |
| printf "(%5d lines)\n", lines; | |
| } | |
| } | |
| # Print line only if in thread dump block | |
| { if (thread_dump!=0) { | |
| print $0 > filename; | |
| lines++; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment