bug-coreutils
[Top][All Lists]
Advanced

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

Re: wc -l doesn't count partial lines


From: Eric Blake
Subject: Re: wc -l doesn't count partial lines
Date: Sun, 25 Jan 2009 10:22:14 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.19) Gecko/20081209 Thunderbird/2.0.0.19 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to address@hidden on 1/25/2009 9:15 AM:
> If a file has no newline at the end of the last line, the last line
> doesn't get counted.  As a minimal test case, try
> 
> % echo foo >test && echo -n bar >>test && wc -l test
> 1

Not a bug.  This behavior is required by POSIX - wc -l is required to
count the number of <newline> characters in the file, and is required to
operate on non-text files (including files that don't end in a <newline>,
in which case the partial text at the end of the file does not count as a
line): http://www.opengroup.org/onlinepubs/9699919799/utilities/wc.html

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkl8n8YACgkQ84KuGfSFAYD6fACgxiCMtuMk0O6eFLHifpJ/nmTM
dQ0An0ZMM854ecScHkLiZDskuqw6USZc
=IgTJ
-----END PGP SIGNATURE-----




reply via email to

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