You're viewing a comment by Jotne and its responses.

Jotne Permalink
August 14, 2013, 07:39

Print 2 lines before and 3 after "pattern"

awk '{a[NR]=$0} $0~s {f=NR} END {for (i=f-B;i<=f+A;i++) print a[i]}' B=2 A=3 s="pattern"<\code>
grep -A3 -B2 "pattern"<\code>

Reply To This Comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "unix_100": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.