bug-coreutils
[Top][All Lists]
Advanced

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

Re: Defect in count result of "wc" command


From: Bob Proulx
Subject: Re: Defect in count result of "wc" command
Date: Mon, 4 Sep 2006 20:43:02 -0600
User-agent: Mutt/1.5.9i

Saifullah QAZI wrote:
>    
 
> 
>    Hi, using cygwin, 'wc' count is alway one less than actual lines in file= .
>    Is that defect or designed.?
>    

The wc program counts newline characters (0x0a) in the file.

  info coreutils wc

  `wc' counts the number of bytes, characters, whitespace-separated
  words, and newlines in each given FILE, ...

It does not really know anything about lines.  For example, are lines
separated by newlines or terminated by newlines?  That has been a
confusing problem for years.  Counting newlines in files is both
unambiguous and also the traditional legacy behavior standardized by
POSIX.  Changing that would break many things.

If the count from wc of newline characters in the file matches the
number of newline characters in the file then it is correct and
everything is working as expected.  If the count from wc of newline
characters in the file does not match the actual number of newline
characters in the file then it would be a bug.

If you have found a bug then please report as small of a test case as
you can that illustrates the problem.  Plus include the version of the
program.  For example:

  echo | wc -l
  1
  wc --version
  wc (GNU coreutils) 6.2-cvs

Bob




reply via email to

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