buggrep - Bugs: bug #23936, grep with "near" and...


You are not allowed to post comments on this tracker with your current authentication level.

bug #23936: grep with "near" and "far-from" support

Submitted by:  None
Submitted on:  Fri 25 Jul 2008 07:34:23 PM UTC  
Category:  None Severity:  1 - Wish
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Fri 25 Jul 2008 07:34:23 PM UTC, original submission:  

It'd be really nice if grep could also search context.  In my case, I'm looking for USING with JOIN nearby.  I'm adapting SQL code that is about to be converted from MySQL 4 to MySQL 5, but I need to clarify USING's.

I'd like to be able to do this:

grep -niR using --nearby-match=join --nearby-lines-before=3

I can also see how it'd be useful to look for strings that are "far from" other strings (the --far-from string is not found in the context described in the --far-from-lines list)

I suggest the following new parameters:

--far-from=<match string>  Requires that match string is not in
                           nearby context.
--near=<match string>      Requires the match string in nearby
--near-lines=<n>           Sets nearby context to the matching
                           line and the n lines before and
--near-lines-before=<n>    Works like --context-before
                           specifically for nearby matches.
--near-lines-after=<n>     As above, but after.
--near-expands-context     Context display expanded to include
                           nearby matches (treats nearby matches
                           as the match line).

On implementation - I think it'd be pretty easy to recursively grep primary match strings for near and far matches to determine if a primary match meets follow-up criteria.



No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by bonzini (Updated the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-12-04 bonzini Severity3 - Normal => 1 - Wish

    Back to the top

    Powered by Savane 3.7