delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/09/01/18:54:14

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
Date: Wed, 1 Sep 2004 18:54:56 -0400
From: Christopher Faylor <cgf-no-personal-reply-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Regular Expressions from Bash Shell
Message-ID: <20040901225456.GJ9891@trixie.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <F76C9B2DA2FC4C4CA0A18E288BBCBCF708217CF7 AT nihexchange24 DOT nih DOT gov>
Mime-Version: 1.0
In-Reply-To: <F76C9B2DA2FC4C4CA0A18E288BBCBCF708217CF7@nihexchange24.nih.gov>
User-Agent: Mutt/1.4.1i

On Wed, Sep 01, 2004 at 06:07:15PM -0400, Buchbinder, Barry (NIH/NIAID) wrote:
>At Wednesday, September 01, 2004 5:17 PM, Igor Pechtchanski wrote:
>> On Wed, 1 Sep 2004, Siegfried Heintze wrote:
>> 
>>> I want to use grep on all the FORTRAN source code files in the
>>> current directory whose file names do not contain a "_" character.
>>> How do I do this? 
>>> 
>>> I'm using the extension of ".f" to designate FORTRAN.
>> 
>> Disclaimer: this is not a shell programming support forum, and the
>> above post is off-topic for this list, since it asks a general shell
>> question not related to Cygwin.
>> 
>> But, since I'm sending this e-mail anyway (and I hope this in no way
>> encourages similar future posts):
>> 
>> find . -name \*_\* -o -name \*.f -print | xargs grep EXPRESSION
>
>I think a "!" was forgotten.
>
>find . \( ! -name \*_\* \) -o -name \*.f -print | xargs grep EXPRESSION
>
>The parentheses may not be needed -- you can try it both ways.

I don't think either of those meets the letter of the original request.

If you only want the files in the current directory then something like:

ls -d *.f | grep -v '^_' | xargs grep EXPRESSION

should work better.

Or if you use zsh you can just do:

grep EXPRESSION *.f~_*

cgf

--
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