LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Extracting block of text from log file (https://www.linuxquestions.org/questions/programming-9/extracting-block-of-text-from-log-file-845935/)

hattori.hanzo 11-22-2010 10:09 PM

Extracting block of text from log file
 
I have a log file and want to extract all blocks of text that start with START and ends with END. Each block is 5 lines.

Code:

--- START

blah blah blah

--- END

I was thinking of :

Code:

grep -A 5 "--- START" file
What would I use if each block was 'not' 5 lines?

Thanks & Regards

syg00 11-22-2010 10:55 PM

Use sed - you can use the START and END as address range delimeters.
For simple requirements does the job fine.


All times are GMT -5. The time now is 11:43 PM.