How to find a specific word between two lines having same another word..
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to find a specific word between two lines having same another word..
Hi,
First of all apologies for that poor statement I wrote - my bad english :-(
Let me elaborate in example what I exactly need.
I have a java app log file containing different exceptions.
Code:
$ vi java.log
2013-01-23 21:19:32,621 INFO [STDOUT] (my-nio-server-WorkerThread-4029) [LCDS]01/23/2013 GatewayEndpoint 'gateway-endpoint' failed to process a synchronized authentication.
flex.messaging.security.SecurityException: External login command required. Please check your security configuration.
at flex.messaging.security.LoginManager.login(LoginManager.java:245)
at flex.messaging.endpoints.GatewayEndpoint$GatewayEndpointProtocolHandler.processAuthenticationSyncOperation(GatewayEndpoint.java:874)
at flex.messaging.endpoints.GatewayEndpoint$GatewayEndpointProtocolHandler.processReceivedGatewayMessage(GatewayEndpoint.java:836)
at flex.messaging.endpoints.GatewayEndpoint$GatewayEndpointProtocolHandler.processReceivedMessage(GatewayEndpoint.java.exception:779)
at flex.messaging.endpoints.AMFSocketProtocolHandler.processReceivedMessageChunk(AMFSocketProtocolHandler.java:158)
at flex.messaging.io.amfsocket.AMFSocketInput.read(AMFSocketInput.java:139)
at flex.messaging.endpoints.AMFSocketProtocolHandler.doRead(AMFSocketProtocolHandler.java:132)
2013-01-23 22:30:44,044 INFO [org.apache.axis2.transport.http.HTTPSender] (http-0.0.0.0-8080-9) Unable to sendViaPost to url[https://www.zuora.com/apps/services/a/43.0]
org.apache.commons.httpclient.ConnectionPoolTimeoutException: Timeout waiting for connection
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.doGetConnection(MultiThreadedHttpConnectionManager.java:497)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.getConnectionWithTimeout(MultiThreadedHttpConnectionManager.java:416)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:153)
at org.apache.commons.httpclient.HttpClient.execute(HttpClient.java.exception:397)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:621)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)
2013-01-23 22:30:44,044 INFO [org.apache.axis2.transport.http.HTTPSender] (http-0.0.0.0-8080-9) Unable to sendViaPost to url[https://www.zuora.com/apps/services/a/43.0]
org.apache.commons.httpclient.ConnectionPoolTimeoutException: Timeout waiting for connection
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.doGetConnection(MultiThreadedHttpConnectionManager.java:497)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.getConnectionWithTimeout.exception(MultiThreadedHttpConnectionManager.java:416)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:153)
I want to find how many "exception" words are there between line having "INFO" word in them.
ie. for example, in below section there are two exception errors..
Code:
2013-01-23 21:19:32,621 INFO [STDOUT] (my-nio-server-WorkerThread-4029) [LCDS]01/23/2013 GatewayEndpoint 'gateway-endpoint' failed to process a synchronized authentication.
flex.messaging.security.SecurityException: External login command required. Please check your security configuration.
at flex.messaging.security.LoginManager.login(LoginManager.java:245)
at flex.messaging.endpoints.GatewayEndpoint$GatewayEndpointProtocolHandler.processAuthenticationSyncOperation(GatewayEndpoint.java:874)
Unable to sendViaPost to url[https://www.zuora.com/apps/services/a/43.0]
org.apache.commons.httpclient.ConnectionPoolTimeoutException: Timeout waiting for connection
2013-01-23 22:30:44,044 INFO [org.apache.axis2.transport.http.HTTPSender] (http-0.0.0.0-8080-9) Unable to sendViaPost to url
I want to find how many "exception" words are there between line having "INFO" word in them.
Please provide a sample output file which corresponds to the sample input file already posted. That, along with your words, will help us to understand your goal.
Yeah, I should've thought of that. I hate having to fight with awk's lack of easy array control and tend towards the laziest approach. awk really needs to get a few built-in array and field range functions; splicing and sorting can be so annoying.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.