Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 622
  • Last Modified:

Shell script awk/grep

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
srikanthrad
Asked:
srikanthrad
1 Solution
 
PatTheDBACommented:
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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now