GAWK Find Pattern Print Lines Before and After
Using grep I can easily use:
Code:
cvs log |grep -iB 10 -A 10 'date: 2013-10-30' |
I can't really see why you would want to do it with awk, but
^^ untested ( as well as unwritten as awk ) it can be done, but I don't know why since grep -C10 will do the same with less effort NOTE:, there is probably a much better way of doing it in awk than my above 'logic' |
Quote:
With this InFile ... Code:
line 01 Code:
gawk '{l[NR]=$0; if ($0~"date: 2013-10-30") {for (j=NR-3;j<=NR+2;j++) {a[j]=1}; a[j]=a[j]+99}} Code:
line 01 |
thanks for the reply. You have left me speechless on how long it would take to use gawk instead of simply using grep.
|
All times are GMT -5. The time now is 02:54 AM. |