[SGVLUG] Grep and the command line...

BB Odenthal bb.odenthal at gmail.com
Fri Jun 1 11:49:48 PDT 2007


The extended regex /\t"?/ will search for a tab followed by zero or one double quotes. So this will match the following:

<Tab>"
<Tab>

You can also write it as /\t"{0,1}/

-bb
  

-----Original Message-----
From: "Emerson, Tom (*IC)" <Tom.Emerson at wbconsultant.com>
Date: Fri, 1 Jun 2007 11:37:16 
To:"SGVLUG Discussion List." <sgvlug at sgvlug.net>
Subject: [SGVLUG] Grep and the command line...

First off, I'll admit I'm NOT a regex "guru", but I'm getting better.
Now I have a search that sorta has me stumped (and part of the problem
is that I'm doing this using the microsoft "SFU"(*) version of grep at
the DOS command line)

Here's the deal: I have a tab-delimited file that appears to have a
mismatched "quote" somewhere.  For example, the file /should/ look like
this:


-->key   <tab>description.....      <tab>123<tab>456<tab>etc.

Note that "description" is an essentially free-form text field.  Any
actual "tabs" in the data (description) have been converted to "<t>".
Somewhere in the file I have this:

-->key   <tab>"description....       <tab>123<tab>456<tab>etc.

Note the subtle inclusion of a double-quote character at the begninning
of the description, but not at the end.  This "quote" character is part
of the actual data.  As a result, the process importing the file sees
the initial quote character, strips it from the field, and looks for a
corresponding close-qoute.  Since it doesn't see it before the CR/LF, it
includes THE REST OF THE LINE as part of the description!

So, how do I search for the sequence <tab><double-quote>?

Bonus points for "how do I actually type this in at a command line"?
(using the aforementioned DOS command line and Microsoft's version of
grep?)

Tom

(*) SFU = Services for Unix -- a freebie from MS that includes a bash
shell, tab-completion [within DOS!] and a fairly standard assortment of
"basic tools"


More information about the SGVLUG mailing list