public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Question regarding grep 2,6,3 regular expression looking for lines without something in a part of a line
@ 2014-10-08 14:00 Larry W. Virden
  2014-10-08 14:24 ` Eric Blake
  2014-10-08 15:35 ` Nick
  0 siblings, 2 replies; 3+ messages in thread
From: Larry W. Virden @ 2014-10-08 14:00 UTC (permalink / raw)
  To: cygwin

I am using an older version of cygwin on a Windows 7 PC.
I have a file of data that is formatted in character separated value format.
For example, a couple of lines might be:

"Doe, John";"Student";"Senior"
"Admin";"Staff";

Now, I want to perform a grep that returns lines that do not have a
comma in the "first column" of data.

I tried the obvious
grep '^"[^,"]";' file.csv
but did not get the results desired. I got nothing returned - but I
know there are lines like the admin line in the data.

I know there are all sorts of extended regular expression atoms
available; is this a case where I need egrep and something unique to
express the requirements?

-- 

Larry W. Virden
http://www.facebook.com/lvirden/
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question regarding grep 2,6,3 regular expression looking for lines without something in a part of a line
  2014-10-08 14:00 Question regarding grep 2,6,3 regular expression looking for lines without something in a part of a line Larry W. Virden
@ 2014-10-08 14:24 ` Eric Blake
  2014-10-08 15:35 ` Nick
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2014-10-08 14:24 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 796 bytes --]

On 10/08/2014 08:00 AM, Larry W. Virden wrote:
> I am using an older version of cygwin on a Windows 7 PC.
> I have a file of data that is formatted in character separated value format.
> For example, a couple of lines might be:
> 
> "Doe, John";"Student";"Senior"
> "Admin";"Staff";
> 
> Now, I want to perform a grep that returns lines that do not have a
> comma in the "first column" of data.
> 
> I tried the obvious
> grep '^"[^,"]";' file.csv

That looks for lines containing a literal quote, then exactly one quoted
character that is neither comma nor quote, then another literal quote.
You forgot the *:

'^"[^,"]*";'

Your question is not cygwin-specific.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question regarding grep 2,6,3 regular expression looking for lines without something in a part of a line
  2014-10-08 14:00 Question regarding grep 2,6,3 regular expression looking for lines without something in a part of a line Larry W. Virden
  2014-10-08 14:24 ` Eric Blake
@ 2014-10-08 15:35 ` Nick
  1 sibling, 0 replies; 3+ messages in thread
From: Nick @ 2014-10-08 15:35 UTC (permalink / raw)
  To: cygwin


You need a quantifier, such as '+':

grep '^"[^,"]+";' file.csv




--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-08 15:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-08 14:00 Question regarding grep 2,6,3 regular expression looking for lines without something in a part of a line Larry W. Virden
2014-10-08 14:24 ` Eric Blake
2014-10-08 15:35 ` Nick

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).