Little awk help

I am attempting to pull everything between a regex and the next blank line from a file. I am having trouble with the regex for a blank line. Here is what I tried.

awk '/Online modules/, /^$/' filename.txt

I also tried variations with \n and \n\n and am not having any luck. I keep getting everything from the first regex through until the end of the file. Any help is appreciated, thanks in advance.

That works for me.

Perhaps you have carriage returns at the end of the otherwise blank line?

Probably the start / stop regex given to awk doesn't match. Can you post here the output of cat -vet filename

Try this one:

awk '/Online modules/{f=1}f && /^$/{exit}f' filename.txt

@danmero, same result, from the regex to the end of the file.

The file is rather large, so performed the cat -vet and included a few lines before my first regex through to a few lines after the blank line. I also omitted much of what was between. Also, I know Online is spelled differently than what I originally included. I simplified it a bit for my post. But here is the contents. Basically, I want to pull the block of text that starts On-line (non screened) through until a blank line appears, then stop. The following section might not always say Operations Libraries, it could be something else, that is why I have to key on the blank line as my ending regex. Thanks again guys!

  • W2715010 $
    +-> PsAD : ZH5010_271_TEST_WINDOW member name: ZH501027 $
    $
    On-line (non screened) load modules $
  • HA05X30 $
  • HA05X40 $
    +-> AcBlk : CAB_BA_ALL_B_CASH_RECEIPTS_IO member name: HA05B34 $
  • HA06X20 $
    +-> AcBlk : CAB_BA_PREM_ASO_CASH_RCPT_DRIVER member name: HA06N22 $
    +-> AcBlk : CAB_BA_PREM_ASO_CASH_RCPT_IO member name: HA06B24 $
  • HA06X23 $
    +-> AcBlk : CAB_BA_PREM_ASO_CASH_RP_DR member name: CABBAPR1 $
  • HA09X00 $
    +-> AcBlk : CAB_BA_INVOICE_POSTING_DRIVER member name: HA09B02 $
    +-> AcBlk : CAB_ME_PURGE_INACTIVE_MPNA member name: HZMHN07 $
    +-> AcBlk : CAB_ME_PURGE_INACTIVE_MPCP member name: HZMHN08 $
  • HZMIX00 $
    +-> PsAD : ME_PURGE_INACTIVE_DATA_4_N member name: HZMIN01 $
    +-> AcBlk : CAB_ME_PURGE_INACTIVE_DATA_4_DRV member name: HZMIN02 $
    +-> AcBlk : CAB_ME_PURGE_INACTIVE_MLVL member name: HZM1N03 $
    +-> AcBlk : CAB_ME_PURGE_INACTIVE_MREI member name: HZM1N04 $
    +-> AcBlk : CAB_ME_PURGE_INACTIVE_MBRH member name: HZM1N05 $
    +-> AcBlk : CAB_ME_PURGE_INACTIVE_OINS member name: HZM1N06 $
    +-> AcBlk : CAB_ME_PURGE_INACTIVE_PEXE member name: HZM1N07 $
    +-> AcBlk : CAB_ME_PURGE_INACTIVE_PREX member name: HZM1N08 $
    $
    Operations Libraries $
  • CLBENE $
    +-> AcBlk : CAB_CL_BENE_ELIG_MANUAL_OVERRIDE member name: HC20B02 $
  • CLDUPE $
    +-> AcBlk : CAB_CL_DUP_CHECK_DRIVER member name: CABCLDUP $

It seems that you have a nonprintable character on the end of every line, try:

awk '/Online modules/,/^.$/' file

Regards

Try again

awk '/On-line/{f=1}f && /^$/{exit}f' filename.txt

Neither worked, when I vi the file it looks like the line is an entire line of spaces out a record length of 80, perhaps that is why none of these are hitting.

This should print untill the line with only spaces:

awk '/Online modules/,/^[ ]*$/' file

Regards

I should have asked you to attach the file snippet instead of posting it. Anyways no hidden / ctrl characters in the file so your original awk command should work that is...

awk '/^On-line/, /^$/' file

That worked Franklin. Thanks for all the replies, very helpful!

So looks like it wasn't a blank line at all but had whitespace in it.