delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/04/03/14:31:11

X-Spam-Check-By: sourceware.org
From: "Dave Korn" <dave DOT korn AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
References: <mn DOT 1b2c7d742b4ca532 DOT 51129 AT pbs DOT org> <019001c77617$8e0eabc0$2e08a8c0 AT CAM DOT ARTIMI DOT COM> <mn DOT 1b487d74cbed7dfa DOT 51129 AT pbs DOT org>
Subject: RE: grep and exact matches help..
Date: Tue, 3 Apr 2007 19:30:36 +0100
Message-ID: <019601c7761e$2c2531c0$2e08a8c0@CAM.ARTIMI.COM>
MIME-Version: 1.0
X-Mailer: Microsoft Office Outlook 11
In-Reply-To: <mn.1b487d74cbed7dfa.51129@pbs.org>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 03 April 2007 19:01, Kevin Markle wrote:

> In this search I want to get winops only not winops and winops-hq
> 
> kmarkle AT backup /cygdrive/e/wsus/group_1a_DEV
> $ ls -al | grep winops
> -rwx------+ 1 Administrators ???????? 1079474 Apr  2 19:32
> winops-hq_WINDOWSUpdate.log
> -rwx------+ 1 Administrators ????????   18993 Apr  3 13:02
> winops-hq_asr.log
> -rwx------+ 1 Administrators ???????? 1242842 Apr  3 06:01
> winops_WINDOWSUpdate.log
> -rwx------+ 1 Administrators ????????   18580 Apr  3 13:02
> winops_asr.log

  Ummm, you need to be more precise than that.  If you ask for an "exact
match", which to me means "winops not followed by anything at all" from that
search, you'll get nothing because there isn't a file called "winops".

  It seems to me that what you want is not an exact match after all; what you
want is "winops, and it may be followed by some things, but not by some other
things".  You'll need to write a regular expression that allows those first
"some things" while denying the "some other things".

  [BTW we're getting off-topic here, since this is really a generic 'grep'
question and nothing specific to cygwin at all.]

  BTW2, I assume we're still talking about your script from before.
Seriously, use "ls -1" rather than "ls -l" (that is, use a one instead of an
L), because then you get /just/ the filenames, one per line, and won't have to
worry about parsing the name out from amongst all those permission flags and
datestamps.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019