wc does not print the correct totals when given a large number of files:

example ("How big is the linux C-source?"):
# find /usr/src/linux/ -type f -name '*.c' | xargs wc | grep total
 403654 1320103 10885558 total
 619345 2148481 17926183 total
 291311  948158 7473011 total
  91822  300088 2475385 total

The sum of these columns seems to be the correct total. Intuitively wc
should not print more than one total, and I don't think xargs calls wc
more than once (or xargs is broken!).
(Is it the find/xargs combo that makes it fail?). 

My workaround is to do:

find /usr/src/linux/ -type f -name '*.c' | cat | wc

but it still looks like a bug in wc.
Looks like wc behaves the same on Solaris - is this some obscure
buffering problem? At least this should be documented (found nothing
from man or info).

Heres some additional info:
[EMAIL PROTECTED] 246: wc --help
Usage: wc [OPTION]... [FILE]...
Print line, word, and byte counts for each FILE, and a total line if
more than one FILE is specified.  With no FILE, or when FILE is -,
read standard input.
  -c, --bytes, --chars   print the byte counts
  -l, --lines            print the newline counts
  -L, --max-line-length  print the length of the longest line
  -w, --words            print the word counts
      --help             display this help and exit
      --version          output version information and exit

Report bugs to <[EMAIL PROTECTED]>.
[EMAIL PROTECTED] 247: wc --version
wc (GNU textutils) 2.0
Written by Paul Rubin and David MacKenzie.

Copyright (C) 1999 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
[EMAIL PROTECTED] 248: uname -a
Linux tnoox77.alcatel.no 2.2.12-20smp #1 SMP Mon Sep 27 10:34:45 EDT
1999 i686 unknown

Tested on RedHat 6.1.

-- 
James Øyvind Baum                           #include <std/disclaimer.h> 
Alcatel Telecom Norway                           fax: (+47) 22 63 87 10
email: [EMAIL PROTECTED]                     tel: (+47) 22 63 82 72

Reply via email to