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 "---"' -
Thu, 28 Oct 2004grep -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)
0 responses to 'grep -A (after), -B (before) context without gnu grep (-C too...)'Leave a reply
You need javascript enabled to use this form. Anti-spam efforts ongoing. Also,
if the comment doesn't show up, it's because the form expired. Go back and copy
your comment, reload the form, and resubmit. Apologies if this is a hassle, I'm
just playing with antispam methods right now. If this insists on not working,
please email me about it.
|
Search this siteNavigationMetadataHome About Resume My Code (SVN)ArticlesARP Security Dynamic DNS with DHCP OpenLDAP+Kerberos+SASL PPP over SSH SSH Security: /bin/false Week of Unix Tools Work EfficiencyProjectsfex firefox tabsearch firefox urledit grok keynav liboverride newpsm (FreeBSD) nis2ldap pam_captcha poor man's backup Solaris audio utility xboxproxy xdotool xmlpresenter xpathtool misc scriptsPresentationsYahoo! Hack Day '06 Unix Essentials Vi/Vim EssentialsTag CloudCalendar
FriendsBarCamp Kent Brewster Tantek Çelik John Resig Wesley Shields Tyler ShieldsTechnorati |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||