bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wc can not count very large file


From: Jim Meyering
Subject: Re: wc can not count very large file
Date: Thu, 07 Oct 2004 09:10:08 +0200

pwu <address@hidden> wrote:
> I have tried to calculate how many lines in our project.  In one
> directory it give me the value is 160k, but the total number for all
> directories are only 50k.
> my command is like this:
> find . -name '*.[ch]' |xargs wc
> The newlines are only 50K. I have about 20 directories, each has 100k
> to 300k lines. I guess it is because wc use int not long to calculate
> the lines and bytes

Beware of using xargs with wc like that.

If you have too many files to fit in one command-line buffer,
xargs will invoke wc more than once, and you'll end up with two
or more `total' lines.  You're probably seeing only the last one.

coreutils has a TODO item that will eventually address this:

  wc: add an option, --files0-from [as for du] to make it read
    NUL-delimited file name arguments from a file.

Once that option is added, you'll be able to do this:

  find . -name '*.[ch]' -print0 |wc --files0-from

In the mean time, you could use your xargs command
and sum the numbers from the `total' lines.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]