Reading a long literal continued next line

I am trying to identify all messages or prompts from a number of COBOL programs and they can usually be identified by a pair of double quotes on one line. However, sometimes the literal will not be finished on the first line but after a dash in column 7 of the next line, the literal will be continued after the first double quote on that line. This is an example of both:

 02 LINE 11 COL 28 VALUE "or App#".
 02 LINE 1 COL 1 VALUE "************************** Application
 -"Inquiry ******************************".
 

There is a space after Application in column 72 (last column with code) and I need to see "Application Inquiry" with asterisks on either side.

My script of grep '".*"' $1 finds the line with two quotes on them but not those with one.

Thanks in advance.

sed '/Application/,/Inquiry/!d' infile

Try:

perl -ln0e 's/^ -"/-/mg;while (/"[^"]+"/sg){$x=$&;$x=~s/\n/ /g;print $x}' file

Try:

sed -n '/^[^"]*"[^"]*$/N; /".*"/p' file

Out of curiosity.

Would it matter if you just search for one? Would it produce output you don't want?

grep \" $1
2 Likes

Me and my "mountain out of molehill" technique. Thank you and everyone else who posted here.

I have tried to put together a sed script for this:

/\"[^\"]*/{
 N
 s/^[^\"]*\"//
 s/\n.*\"\(.*\)\".*/ \1/
 p
 }
 /^[^\"]*\"\([^\"]*\)\".*/{
 s/^[^\"]*\"//
 s/[^\"].*//p
 }
}

Using this test:

No literal on this line
 02 LINE 11 COL 28 VALUE "or App#".
 No literal here, it shouldn't be displayed.
 02 LINE 1 COL 1 VALUE "************************** Application
 -"Inquiry ******************************".
 Next to last line.
 Last line.

the sed (-n) script displays the final double quote on a stand alone literal as well the following line when it has no quotes at all.
TIA