GNU bug report logs -
#19969
problem: wc -c doesn't read actual # of bytes in file
Previous Next
Reported by: Linda Walsh <coreutils <at> tlinx.org>
Date: Sat, 28 Feb 2015 09:00:03 UTC
Severity: normal
Tags: fixed
Done: Assaf Gordon <assafgordon <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #17 received at 19969 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 02 Mar 2015 06:57, Eric Blake wrote:
> On 02/28/2015 01:59 AM, Linda Walsh wrote:
> > (coreutils-8.21-7.7.7)
> >
> > wc -c(bytes) doesn't seem to reliably read the number
> > of bytes in a file.
> >
> > I was wanting to find out what the largest data-source
> > files in '/proc' and '/sys' (didn't get around to trying
> > /sys, since all the files under /proc/sys return 0 bytes.
>
> The Linux kernel is notoriously bad about advertising 0-length file size
> for non-empty contents of files within sysfs and procfs. Any program
> that trusts just stat() output will report 0; the only way to see
> non-zero sizes on these special files is to open() and read() them (I'm
> not even sure if lseek(SEEK_END) does the trick) - but fixing that is
> something for the kernel folks to do, and not coreutils to work around,
> because it is more than coreutils that is affected by the kernel's lies.
to be fair, for some pseudo files, it's not feasible or possible to report the
real size
`wc -c < /proc/file` should work
-mike
[signature.asc (application/pgp-signature, inline)]
This bug report was last modified 6 years and 215 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.