Visit Our UNIX and Linux User Community


Reading a long literal continued next line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading a long literal continued next line
# 1  
Old 06-05-2014
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:
Code:

 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.
# 2  
Old 06-05-2014
Code:
sed '/Application/,/Inquiry/!d' infile

# 3  
Old 06-05-2014
Try:
Code:
perl -ln0e 's/^ -"/-/mg;while (/"[^"]+"/sg){$x=$&;$x=~s/\n/ /g;print $x}' file

# 4  
Old 06-05-2014
Try:
Code:
sed -n '/^[^"]*"[^"]*$/N; /".*"/p' file

# 5  
Old 06-05-2014
Out of curiosity.

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

Code:
grep \" $1

These 2 Users Gave Thanks to Aia For This Post:
# 6  
Old 06-05-2014
Quote:
Originally Posted by Aia
Out of curiosity.

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

Code:
grep \" $1

Me and my "mountain out of molehill" technique. Thank you and everyone else who posted here.
# 7  
Old 06-09-2014
I have tried to put together a sed script for this:
Code:
/\"[^\"]*/{
 N
 s/^[^\"]*\"//
 s/\n.*\"\(.*\)\".*/ \1/
 p
 }
 /^[^\"]*\"\([^\"]*\)\".*/{
 s/^[^\"]*\"//
 s/[^\"].*//p
 }
}

Using this test:
Code:
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


Moderator's Comments:
Mod Comment Please try to leave out non-functional formatting

Last edited by Scrutinizer; 06-09-2014 at 02:06 PM.. Reason: Formatting

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to avoid "Too many arguments" error, when passing a long String literal as input to a command?

Hi, I am using awk here. Inside an awk script, I have a variable which contains a very long XML data in string format (500kb). I want to pass this data (as argument) to curl command using system function. But getting Too many arguments error due to length of string data(payloadBlock). I... (4 Replies)
Discussion started by: cool.aquarian
4 Replies

2. Shell Programming and Scripting

Reading text file, comparing a value in a line, and placing only part of the line in a variable?

I need some help. I would like to read in a text file. Take a variable such as ROW-D-01, compare it to what's in one line in the text file such as PROD/VM/ROW-D-01 and only input PROD/VM into a variable without the /ROW-D-01. Is this possible? any help is appreciated. (2 Replies)
Discussion started by: xChristopher
2 Replies

3. Programming

Reading long options in C++ program

I am reading arguments passed to a C++ program which accepts long options. Long options start with '--', with the value joined with the option by an = sign, with no intervening spaces. An example is as follows: programName --vdz=15.0 I want to store 'vdz' in variable 'key', whereas... (4 Replies)
Discussion started by: kristinu
4 Replies

4. Solaris

Line too long error Replace string with new line line character

I get a file which has all its content in a single row. The file contains xml data containing 3000 records, but all in a single row, making it difficult for Unix to Process the file. I decided to insert a new line character at all occurrences of a particular string in this file (say replacing... (4 Replies)
Discussion started by: ducati
4 Replies

5. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

6. Shell Programming and Scripting

Bash: Reading out rows of a file into a dynamic array and check first literal

Hello, i have a file "Movie.ini" looking e.g. like follows * MOVIE A bla bla MOVIE B blubb blubb MOVIE C I'd like to read the file "Movie.ini" with cat and grep and check whether it includes the string MOVIE only with a '*' at the beginnig. By doing "cat Movie.ini| grep MOVIE... (14 Replies)
Discussion started by: ABE2202
14 Replies

7. Shell Programming and Scripting

Reading a file line by line and processing for each line

Hi, I am a beginner in shell scripting. I have written the following script, which is supposed to process the while loop for each line in the sid_home.txt file. But I'm getting the 'end of file' unexpected for the last line. The file sid_home.txt gets generated as expected, but the script... (6 Replies)
Discussion started by: sagarparadkar
6 Replies

8. UNIX for Dummies Questions & Answers

reading long filenames from nero to AIX

One of my colleagues is having an issue moving files between a windows box and the AIX servers in the office. The filenames are being truncated though i don't know to what extent. He's using Nero to burn the CD and I think he mentioned he's using Joliet. I found another thread that shows a... (1 Reply)
Discussion started by: categoryzd
1 Replies

9. Shell Programming and Scripting

getting error 0403-016 Cannot find or open the file while reading a long line

Hi, I have an requirement of reading a long line of 7000 chars and cutting it iam doing this : while read -r x do echo $x ......... done < `cat filename` when iam doing this it is giving me "0403-016 Cannot find or open the file." Can anyone let how this can be done. (2 Replies)
Discussion started by: karthee
2 Replies

Featured Tech Videos