Grep starting from a fixed text, until the first blank line
Using awk
Try:
$ awk '/Start to grab/,/^$/' prova.txt
Start to grab from here: 1
random1
random2
random3
random4
Start to grab from here: 2
random1546
random2561
Start to grab from here: 3
random45
random22131
/Start to grab/,/^$/
defines a range. It starts with any line that matches Start to grab
and ends with the first empty line, ^$
, that follows.
Using sed
With very similar logic:
$ sed -n '/Start to grab/,/^$/p' prova.txt
Start to grab from here: 1
random1
random2
random3
random4
Start to grab from here: 2
random1546
random2561
Start to grab from here: 3
random45
random22131
-n
tells sed not to print anything unless we explicitly ask it to. /Start to grab/,/^$/p
tells it to print any lines in the range defined by /Start to grab/,/^$/
.