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

Submitter:  trids <trids>
Submitted:  Mon 25 Apr 2011 04:23:42 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Wont Fix
Privacy:  Public Assigned 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>
Group 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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

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 (Posted a comment)
  • -email is unavailable- added by meyering (Posted a comment)
  • -email is unavailable- added by trids (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-05-18 bonzini StatusNone Wont Fix
        SummaryGrep doesn\'t support \\t as a tab character Grep doesn't support \t as a tab character
    2011-05-18 meyering Open/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.13-bb6a.
    Corresponding source code