delorie.com/archives/browse.cgi | search |
X-Spam-Check-By: | sourceware.org |
Subject: | Re: grep and words |
From: | Jim Easton <jim AT cs DOT ualberta DOT ca> |
To: | cygwin AT cygwin DOT com |
Date: | Thu, 13 Jul 2006 02:12:21 -0600 (MDT) |
CC: | Jim Easton <jim AT cs DOT ualberta DOT ca> |
X-Mailer: | ELM [version 2.4ME+ PL66 (25)] |
Message-Id: | <S561905AbWGMIMV/20060713081224Z+58@sunkay.cs.ualberta.ca> |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
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 |
Hi, Guy Przytula wrote: > > another question from newbie .. > > is it possible with grep to select only the rows where the second word > > applies, because the pattern can occur at different places like : > > row 1 : xxxx yyyy zzz > > row 2 : yyyy xxxx zzz > > I need only the row where word 2 = yyyy > > grep yyyy would also return row 2 > > Thanks for all info > > Best Regards, Guy Przytula As others have pointed out this is hardly a cygwin question and there are lots of ways of doing it. However here is one that fits your sample data (note: it uses egrep and that I've added a couple of test lines): HTH Jim #!/bin/sh egrep '.* *yyyy ' <<'END' xxxx yyyy zzz yyyy xxxx zzz xxxx yyyy zzz xxxx yyyyf zzz END -- 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/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |