Solved

Shell script awk/grep

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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…

740 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