Unix Technical Forum

grep patch

This is a discussion on grep patch within the mailing.openbsd.tech forums, part of the OpenBSD category; --> Hi, When using grep on more that one file, and if the number of lines of trailing context is ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2008, 08:59 AM
Charles Longeau
 
Posts: n/a
Default grep patch

Hi,

When using grep on more that one file, and if the number of lines of
trailing context is greater that the number of remaining lines in the file
after a matching line, grep will display the number of remaining lines of
the next file.

For instance, if you run grep to match a pattern which is on the last line
of file1, with a context set to 2 lines (default) :

$ grep -C "pattern" file1 file2

grep will also return the first 2 lines of file2, even if there's no
matching pattern in it !

Best regards,

Charles Longeau

Index: usr.bin/grep/util.c
================================================== =================
RCS file: /cvs/src/usr.bin/grep/util.c,v
retrieving revision 1.32
diff -u -p -r1.32 util.c
--- usr.bin/grep/util.c 26 Sep 2006 15:55:17 -0000 1.32
+++ usr.bin/grep/util.c 15 Nov 2006 15:49:16 -0000
@@ -119,6 +119,7 @@ procfile(char *fn)
ln.line_no = 0;
ln.len = 0;
linesqueued = 0;
+ tail = 0;
ln.off = -1;

if (Bflag > 0)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:35 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com