Reading file contents until a keyword

Hi Guys,

I need to read a file until I find a blank line. and in the next iteration I want to continue reading from the line I find a keyword.

For ex: my file looks like

[MCOM]
PDS_JOB_ALIAS
CRITERIA_ITEM_TYPE


[BCOM]
PDS_JOB_CRITERIA_ITEM
CRITERIA_ITEM_TYPE

First I want to read the file starting from 2nd line until the blank line.
Next I want to continue reading from the line I find the keyword [BCOM] until the end of the file.

Please help me with it.

Thanks,
shil

How about:

$ sed -n '2,/^$/p' infile
PDS_JOB_ALIAS
CRITERIA_ITEM_TYPE
 
$ sed -n '/\[BCOM]/,$p' infile
[BCOM]
PDS_JOB_CRITERIA_ITEM
CRITERIA_ITEM_TYPE

Thanks a lot guys :slight_smile: