bug-coreutils
[Top][All Lists]
Advanced

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

Re: FYI: wc accepts a new option --files0-from=FILE, ...


From: Jim Meyering
Subject: Re: FYI: wc accepts a new option --files0-from=FILE, ...
Date: Mon, 26 Jun 2006 12:35:18 +0200

Pádraig Brady <address@hidden> wrote:
> The reason for this I think is so that one gets accurate totals,
> as the following will only give subtotals for each invocation of wc,
> if there are enough files to make the cmd line go above the max len.
>
> find -print0 | xargs --null wc

Right.

> Might be worth adding text to that affect,
> as I needed to think for a minute for the reason.
>
> That same can be said for du, or any
> command that produces totals.

Thanks.
That reminds me: I have to update coreutils.texi :)
The description of wc's --files0-from is nearly identical
to that of du.  I've added an example:

Index: doc/coreutils.texi
===================================================================
RCS file: /fetish/cu/doc/coreutils.texi,v
retrieving revision 1.330
retrieving revision 1.331
diff -u -p -u -r1.330 -r1.331
--- doc/coreutils.texi  25 Jun 2006 06:55:08 -0000      1.330
+++ doc/coreutils.texi  26 Jun 2006 10:33:09 -0000      1.331
@@ -2961,6 +2961,28 @@ Print only the newline counts.
 @opindex --max-line-length
 Print only the maximum line lengths.
 
address@hidden address@hidden
address@hidden address@hidden
address@hidden including files from @command{du}
+Rather than processing files named on the command line, process those
+named in file @var{FILE}; each name is terminated by a null byte.
+This is useful when
+the list of file names is so long that it may exceed a command line
+length limitation.
+In such cases, running @command{wc} via @command{xargs} is undesirable
+because it splits the list into pieces and makes @command{wc} print a
+total for each sublist rather than for the entire list.
+One way to produce a list of null-byte-terminated file names is with @sc{gnu}
address@hidden, using its @option{-print0} predicate.  For example, to find
+the length of the longest line in any @file{.c} or @file{.h} file in the
+current hierarchy, do this:
+
address@hidden
+find . -name '*.[ch]' -print0 | ./wc -L --files=- | tail -n1
address@hidden example
+
+Do not specify any @var{FILE} on the command line when using this option.
+
 @end table
 
 @exitstatus




reply via email to

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