photo
Jordan Sissel
geek

Thu, 28 Oct 2004

grep -A (after), -B (before) context without gnu grep (-C too...)

This essentially does grep -C 5 REGEX $FILE. This was a boredom-induced hack
FILE=foo.log
grep -sn REGEX $FILE | \
awk -F: '{print $1}' | \
xapply -f 'A=$((%1-5)); B=$((%1+5)); echo "-----"; \
   sed -ne "${A},${B}p" '$FILE'; \
   echo "---"' - 

Comments: 0 (view comments)
Tags:
Permalink: /geekery/134
posted at: 14:10

Search this site

Navigation

Metadata

Home About Resume My Code (SVN)

Articles

ARP Security Dynamic DNS with DHCP OpenLDAP+Kerberos+SASL PPP over SSH SSH Security: /bin/false Week of Unix Tools Work Efficiency

Projects

fex firefox tabsearch firefox urledit grok keynav liboverride newpsm (FreeBSD) nis2ldap pam_captcha poor man's backup Solaris audio utility xboxproxy xdotool xmlpresenter xpathtool misc scripts

Presentations

Yahoo! Hack Day '06 Unix Essentials Vi/Vim Essentials

Tag Cloud

Calendar

< October 2004 >
SuMoTuWeThFrSa
      1 2
3 4 5 6 7 8 9
10111213141516
17181920212223
24252627282930
31      

Friends

BarCamp Kent Brewster Tantek Çelik John Resig Wesley Shields Tyler Shields

Technorati