newbie question

David Bolen db3l at fitlinxx.com
Wed Jul 4 15:59:23 EDT 2001


Roman Suzi <rnd at onego.ru> writes:

> If you are working under UNIX, you do not need to program it:
> 
> $ find . -name '*.py' | xargs wc
> 
> (this brokes only when there are too large number of files, but then you
> could read man find to see how to call a command for each file.)

Unless you need an overall total for all files (as opposed to the per
file count request) this shouldn't break at all.  xargs will chunk the
file list out of find into smaller pieces to avoid overflowing command
line arguments to wc.  Thus, for long lists you'll execute wc more
than once, so you'll end up with more than one set of final totals.

(Or you could use "-l 1" with xargs and it'll run wc for each file so
you'll never see total lines :-))

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list