[SGVLUG] Grep and the command line...
Emerson, Tom (*IC)
Tom.Emerson at wbconsultant.com
Fri Jun 1 12:41:30 PDT 2007
Actually, I want to find where a quote immediately follows a tab -- the
"normal" case is that it doesn't, so "tab only" searching would find
every line in the file.
In any case, the real difficulty comes in specifying the quote character
-- remember, this is being done in DOS, not bash/ksh/csh/whatever-sh.
When I type in this:
C:\> grep /"/ CV5055
And then press <tab> [to auto-complete the filename] it changes to this:
C:\> grep /"/"CV5055_active.tab"
Thus making the filename part of the search string and not the actual
target of grep.
==========
OK, Specifics: here is -ONE- record that is causing a problem:
C:\Vanguard\EXTRACTS\CR2>grep "T1202 00TR" CV5055_active.tab
T1202 00TR 01 "DISP 12CT TRAY 0 EA [...snip...]
C:\Vanguard\EXTRACTS\CR2>grep "T1202 00TR" CV5055_active.tab | OD -c
0000000 \t T 1 2 0 2 0 0 T R 0 1
0000020 \t " D I S P 1 2 C T T R A Y
0000040 \t 0 \t E A \t [snipped here]
Note the second line of the dump begins with a tab (\t) followed
immedately by a quote character -- that's the pattern I want to find
elsewhere in the file.
It seems the DOS version of grep doesn't understand "\t" as "tab", which
also makes things tough to find...
> -----Original Message-----
> From: sgvlug-bounces at sgvlug.net
> [mailto:sgvlug-bounces at sgvlug.net] On Behalf Of BB Odenthal
> Sent: Friday, June 01, 2007 11:50 AM
> To: SGVLUG Discussion List.
> Subject: Re: [SGVLUG] Grep and the command line...
>
>
> 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