Solved

Shell script awk/grep

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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 …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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