I have a file prova.txt like this: Start to grab from here: 1fix1fix2fix3fix4random1random2random3random4extra1extra2blaStart to grab from here: 2fix1fix2fix3fix4random1546random2561extra2blablaStart to grab from here: 1fix1fix2fix3fix4random1random22131and I need to grep out from Start to grab here to the first blank line. The output should be like this:Start to grab from here: 1fix1fix2fix3fix4random1random2random3random4Start to grab from here: 2fix1fix2fix3fix4random1546random2561Start to grab from here: 1fix1fix2fix3fix4random1random22131As you can see the lines after Start to grab here are random, so -A -B grep flag don't work: cat prova.txt | grep Start to grab from here -A 15 | grep -B 15 ^$ > output.txtCan you help me to find a way that catch the first line that will be grabbed (as Start to grab from here), until a blank line. I cannot predict how many random lines I will have after Start to grab from here. Any unix compatible solution is appreciate (grep, sed, awk is better than perl or similar).EDITED: after brilliant response by @john1024, I would like to know if it's possible to:1 sort the block (according to Start to grab from here: 1 then 1 then 2)2 remove 4 (alphabetically random) lines fix1,fix2,fix3,fix4 but are always 43 eventually remove random dupes, like sort -u command Final output shoul be like this:# fix lines removed - match 1 first timeStart to grab from here: 1random1random2random3random4#fix lines removed - match 1 second timeStart to grab from here: 1#random1 removed cause is a duperandom22131#fix lines removed - match 2 that comes after 1Start to grab from here: 2random1546random2561or # fix lines removed - match 1 first time and the second tooStart to grab from here: 1random1random2random3random4#random1 removed cause is a duperandom22131#fix lines removed - match 2 that comes after 1Start to grab from here: 2random1546random2561The second output is better that the first one. Some other unix command magic is needed. 
Grep starting from a fixed text, until the first blank line
sed;awk;regular expression;sort