Given this input file:
SectionMarker and some random text here
this is the text in section 1
this is the text in section 1
this is the text in section 1
etc
SectionMarker and some random text here also
this is the text in section 2
this is the text in section 2
this is the text in section 2
etc
SectionMarker and some random text too
this is the text in section 3
this is the text in section 3
this is the text in section 3
etc
How do I split this file in pieces using awk or sed or whatever ?
This is what I tried, but didn’t work:
awk -vRS='\SectionMarker[:print:]\n' 'NR==1 {print}' ./data.log
this one-liner should do the job:
test
i don’t know how many sections in your real problem you want to grab. you could place
exit;in that onliner to make awk not process the whole file.