|
From: | James Dennis |
Subject: | Re: [bug-cflow] 1 line, no newline, wc says 0 lines |
Date: | Fri, 14 Oct 2016 09:32:11 -0400 |
Hi James,
> I was writing data to a file and ran `wc -l <file>` on it to check if the
> file had output. wc kept reporting 0, so I assumed there was no data.
That's quite correct. The -l switch instructs wc to report the number
of newline characters (not lines!) in the input file. Your file had
none, so you were returned 0.
To test if file is not empty, use "test -s <file>".
Quoting man page for wc:
DESCRIPTION
Print newline, word, and byte counts for each FILE
[...]
-l, --lines
print the newline counts
> I found `wc.c` in cflow's source inside the `doc/` directory and was easy
> enough to adjust for this specific case.
(A minor clarification regarding this file: it is not the source of the
system wc utility, although it does the same job. The wc utility on most
GNU/Linux systems comes from the coreutils package
[http://www.gnu.org/software/coreutils/coreutils ]. Other Unices provide
their own versions as well.
The purpose of wc.c in cflow is to serve as an example source to
illustrate its functionality).
> My experience may be the intended behavior. The COUNT macro certainly
> suggests this, but I found it misleading and would love to patch it if the
> cflow team agrees.
Thanks for proposition, but that's the way standard wc works, so it
should not be changed.
Best regards,
Sergey
[Prev in Thread] | Current Thread | [Next in Thread] |