buggrep - Bugs: bug #33159, Grep doesn't support \t as a tab...

 
 

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

bug #33159: Grep doesn't support \t as a tab character

Submitted by:  trids <trids>
Submitted on:  Mon 25 Apr 2011 04:23:42 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Wont Fix
Privacy: PublicAssigned to: None
Open/Closed: Closed

Wed 18 May 2011 05:49:51 PM UTC, comment #3:

"sed is not grep" (and vice versa) is the right answer. Anyway, yes, grep 2.7 also has -P which supports \t.

Paolo Bonzini <bonzini>
Wed 18 May 2011 05:48:46 PM UTC, comment #2:

GNU grep does provide the --perl-regexp (-P) option.
If you don't see it listed in --help, then you may want to take that up with whoever built it (a distribution?). That feature can be compiled-out.

Jim Meyering <meyering>
Project Administrator
Tue 10 May 2011 04:21:40 PM UTC, comment #1:

I am happy to report that I have a found a version of grep which DOES recognise tabs!!!

UnxUtils (http://unxutils.sourceforge.net/) have version 2.5.1 which employs a commandline switch "-P" to honour perl-style regexps.

So ALL the examples I posted earlier will work with UnxUtils' updated grep as follows:

grep -Pine "\tbcp" sqlscripts.sql
grep -Pine "[\t]bcp" sqlscripts.sql
grep -Pine "\x09bcp" sqlscripts.sql

.. which makes the world a better place ;o)

trids <trids>
Mon 25 Apr 2011 04:23:42 PM UTC, original submission:

Hi folks.

Grep doesn't support \t as a tab character in search patterns, as sed does.

EXAMPLE - Find "bcp" preceded by a tab character in a script file:
grep -ine "\tbcp" sqlscripts.sql
grep -ine "[\t]bcp" sqlscripts.sql

This shortcoming is amplified by having no suitable workaround. Even this does not work:
grep -ine "\x09bcp" sqlscripts.sql

I am running version 2.5.4 in the form of GnuWIN32's grep (ie: on a Windows machine), where the closest I can find to a workaround is to paste a tab character, that was typed in from the keyboard, into the search pattern. Clearly, this is not always viable. Which is why characters such as tabs have escape sequences such as \t in the first place.

It is also not sufficient to say that "sed is not grep" as per #23535, as that does not solve anything.

TIA.

trids <trids>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bonzini (Posted a comment)
  • -unavailable- added by meyering (Posted a comment)
  • -unavailable- added by trids (Submitted the item)
  •  

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

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 18 May 2011 05:49:51 PM UTCbonziniStatusNone=>Wont Fix
      SummaryGrep doesn\'t support \\t as a tab character=>Grep doesn't support \t as a tab character
    Wed 18 May 2011 05:48:46 PM UTCmeyeringOpen/ClosedOpen=>Closed
      SummaryGrep doesn\'t support \\t as a tab character=>Grep doesn't support \t as a tab character

    Back to the top


    Powered by Savane 3.1-cleanup1