Solved

Shell script awk/grep

Posted on 2010-09-21
1
573 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
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now