‏إظهار الرسائل ذات التسميات Grep. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات Grep. إظهار كافة الرسائل

الاثنين، 23 مارس 2020

Grep - Print N Lines Before and After Match: Unix Command

1. Grep Overview

In this tutorial, We'll learn how to print before and after grep command results content for each match in UNIX.

In my work some days back, I was using a UNIX grep command on the log file. My job is to find the exceptions in the log file and get the complete exception stack trace. But when we do the following command returns only the line that matches the Exception word.

grep 'Exception' apllication.log


After doing research on grep command, found useful flags that are very helpful. Before that just see the useful use case.

Print Before and After Lines Using Grep