How to display, for example, 10 lines before a found record and 10 lines after a found record when we have two of the same string in one file ? See file example (RECORD in line 10 is our search):
<Test1> </Test1>
<Test2> </Test2>
<Test3> </Test3>
<Test4> </Test4>
<Test5> </Test5>
<Test6> </Test6>
<Test7> </Test7>
<Test8> </Test8>
<Test9> </Test9>
<Test10> **RECORD** </Test10>
<Test11> </Test11>
<Test12> </Test12>
<Test13> </Test13>
<Test14> </Test14>
<Test15> RECORD </Test15>
<Test16> </Test16>
<Test17> </Test17>
<Test18> </Test18>
<Test19> </Test19>
<Test20> </Test20>
I tried something like this:
grep -m 1 -B 10 -A 10 RECORD *
but this only works until the next record met (lines from 1 to 14) and I would like to find all the lines I am looking for.
I expect such a result (aims for the result for the first value):
<Test1> </Test1>
<Test2> </Test2>
<Test3> </Test3>
<Test4> </Test4>
<Test5> </Test5>
<Test6> </Test6>
<Test7> </Test7>
<Test8> </Test8>
<Test9> </Test9>
<Test10> **RECORD** </Test10>
<Test11> </Test11>
<Test12> </Test12>
<Test13> </Test13>
<Test14> </Test14>
<Test15> RECORD </Test15>
<Test16> </Test16>
<Test17> </Test17>
<Test18> </Test18>
<Test19> </Test19>
<Test20> </Test20>