[EMAIL PROTECTED] 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.


_______________________________________________
Bug-coreutils mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to