Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble parsing data: how to account for various extra characters

Status
Not open for further replies.

doublea1535

IS-IT--Management
Feb 1, 2006
30
US
Hello all,

I am trying to parse a field of info from a text file. The issue at the moment is that there can be extra characters between the anchor that I am using to search for and the actual value that I need. For example :


Code:
Problem Description: Network connection timed out.

Code:
Problem Description:
Network connection timed out.

Code:
Problem Description: =20=20=20
blahblahblahblah
Network connection timed out.

What I need to do is get the entire text from "Problem" until the first period at the end of the sentence. How could I do this even if the output spans multiple lines? I was just using grep until I discovered that the data can span multiple lines at times. When this happens I don't get the output I need.

Please help!
 
A starting point:
awk 'BEGIN{RS="."}/Problem Description/' /path/to/textfile

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Well, that works perfect if "Problem Description:" is the first line of text in the file. But that is not the case in my instance and I am unable to make it that way.

Thanks for the hint, I will keep digging.
 
How about:

[tt]awk '/Problem Description/,/Network connection timed out./' inputfile[/tt]

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top