www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/10/04/15:41:23

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Message-ID: <20021004194108.64883.qmail@web40505.mail.yahoo.com>
Date: Fri, 4 Oct 2002 12:41:08 -0700 (PDT)
From: Sheryl McKeown <iboulder AT yahoo DOT com>
Reply-To: smckeown AT mac DOT com
Subject: Re: Problems with find -exec somecommand | tosomeother command
To: cygwin AT cygwin DOT com
In-Reply-To: <5.1.0.14.2.20021004120104.02037908@pop3.cris.com>
MIME-Version: 1.0

Hi Randall,

Thanks for the explanation and the working version.  

Best,
Sheryl

--- Randall R Schulz <rrschulz AT cris DOT com> wrote:
> Sheryl,
> 
> [ Non-Cygwin-specific ]
> 
> 
> Here's how I'd do this:
> 
>          find . -name "*.frm" -exec wc -l {} ;
> 
> 
> The result looks something like this (I changed the
> ".frm" suffix to 
> ".java" for the purpose of finding some files on my
> system):
> 
>     1114 ./DeferredUpdateKB.java
>      295 ./Definitor.java
>       93 ./FlatFormatStrategy.java
>       59 ./FormatStrategy.java
>      139 ./FormattingCursor.java
>      111 ./FormulaPrinter.java
>       77 ./FormulaRenderer.java
>     1379 ./KBContext.java
>     4503 ./KIF3.java
>      191 ./KIF3Constants.java
>      544 ./KIF3Generator.java
>      293 ./KIF3InfixPrinter.java
>     2431 ./KIF3TokenManager.java
>       91 ./LexicalGenerator.java
>     1912 ./NameTable.java
>      298 ./ParseActions.java
>      192 ./ParseException.java
>      913 ./PrefixPrinter.java
>      175 ./PrettyFormatStrategy.java
>      401 ./SimpleCharStream.java
>     1848 ./TauTest.java
>       81 ./Token.java
>      133 ./TokenMgrError.java
> 
> 
> To let you know why what you tried wasn't working,
> you must realize that 
> the pipe split the "find" command (and the "cat"
> subprocesses it spawns) 
> from the "tail" command. The "-exec" option of find
> is pretty much just a 
> means of invoking the Unix "exec(2)" system call. It
> is not like the 
> "system(3)" library routine, which uses a shell to
> interpret the command 
> string.
> 
> If you want pipelines, glob expansion or other shell
> features in the 
> commands executed by the "-exec" option, you should
> use "sh -c" or "bash 
> -c". Note, too, that in that case the command
> argument to the "-c" option 
> must be a single argument. This can get tricky as
> far as quoting and all. 
> Fortunately, the "{}" marker into which the current
> "find" target is 
> substituted does work when embedded within a larger
> string--it need not be 
> an total, isolated "find" argument.
> 
> Good luck.
> 
> Randall Schulz
> Mountain View, CA USA
> 
> 
> At 11:39 2002-10-04, Sheryl McKeown wrote:
> >Hello,
> >
> >I'm attempting to find the number of lines in each
> >file of a source directory.
> >
> >Using bash, I'm using the following command:
> >
> >find . -name "*.frm" -exec cat -n {} | tail -n1 ;
> >but it returns the error
> >
> >cfind: missing argument to `-exec'
> >tail: ;: No such file or directory
> >
> >I've tried various quoting schemes but I can't seem
> to
> >get it to work.
> >
> >I am running XP Prof SP1.
> >
> >Any help is appreciated.
> >
> >-Sheryl
> 
> 
> --
> Unsubscribe info:     
> http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
> 


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.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