Solved

Shell script awk/grep

Posted on 2010-09-21
1
604 Views
Last Modified: 2012-05-10
2010-09-20 07:20:52,545 INFO front-end : entering toMessage [[TransferObject: message = <
type : NEW_ORDER
2010-09-20 07:20:52,545 INFO front-end : entering toMessage [[TransferObject: message = <
type : FILL
2010-09-20 07:20:52,545 INFO front-end : entering toMessage [[TransferObject: message = <
type : AMEND

There are several types of Orders, but I want to grep only those whose first line has
 INFO front-end : entering toMessage [[TransferObject: message = <
and second line
has type : NEW_ORDER in it.

How can I do that? Please suggest
0
Comment
Question by:srikanthrad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
PatTheDBA earned 500 total points
ID: 33727815
try this:
grep -A 1 "INFO front-end" <file to grepin> |grep "NEW_ORDER" -B 1

the -A gives you one line of context after the first line and the second grep (with -B) gives you one line of context before the grep.  Together you get exactly what you want
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question