[Top][All Lists]
[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 11:36:29 +0200 |
address@hidden wrote:
> Jim Meyering wrote:
...
>> 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.
>
> The following should do that automatically:
>
> find . -name '*.[ch]' -print0 |
> xargs -r0 wc -l |
> grep -E "[0-9]+ total" |
> tr -s ' ' |
> cut -f2 -d' ' |
> (tr '\n' +; echo 0) |
> bc
That'd work as long as no file name matches "[0-9]+ total" :-)
You could use a tighter regexp, but there's still the possibility
of a false positive.
Try the above with a file created like this:
touch "$(printf 'bar\n999999999999999 total\nfoo.c')"
And I've just realized that my suggestion undercounts when
wc is invoked with just one file, since there is no `total'
line in that case.