Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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: <5.1.0.14.2.20021004120104.02037908@pop3.cris.com> X-Sender: rrschulz AT pop3 DOT cris DOT com Date: Fri, 04 Oct 2002 12:18:58 -0700 To: cygwin AT cygwin DOT com From: Randall R Schulz Subject: Re: Problems with find -exec somecommand | tosomeother command In-Reply-To: <20021004183901.72574.qmail@web40501.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed 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/