GNU bug report logs -
#17553
du unit suggestion
Previous Next
Reported by: Reuben Thomas <rrt <at> sc3d.org>
Date: Thu, 22 May 2014 19:48:02 UTC
Severity: normal
Tags: notabug
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 17553 <at> debbugs.gnu.org (full text, mbox):
On 05/22/2014 08:47 PM, Reuben Thomas wrote:
> It would be helpful to this addle-pated individual if du would output the
> same units as it accepts as SIZE inputs, so that one could more readily
> tell whether one was getting 1000-based or 1024-based units.
>
> For additional clarity, it would help if for output the suffix were "B" as
> at present for 1000-based units and "iB" for 1024-based (and
> correspondingly it would be nice if "iB" suffixed units were accepted as
> input. As far as input goes, it's backwards-compatible; it's not for output
> if other programs are trying to parse the human-readable output, but maybe
> that's not a problem.
Yes this is not ideal, but it half does what you want:
With this file:
$ truncate -s 1MiB file.in
We can output the appropriate suffixes for a _particular_ power.
$ du --apparent-size -BKiB file.in
1024KiB file.in
$ du --apparent-size -BKB file.in
1049kB file.in
However if we want to auto scale the number with -h we lose the suffix,
and have an ambiguity:
$ du --apparent-size -h file.in
1.0M file.in
$ du --apparent-size -h --si file.in
1.1M file.in
If you wanted to get auto scaling with suffixes you could use
the new numfmt utility which has various number formatting options.
The advantage of that is it concentrates the myriad of number formatting
options in a single location, and allows processing of numbers before
final presentation by numfmt. For example:
$ du -B1 . | sort -k1,1n | numfmt --to=iec-i | tail -n5
104Mi ./gnulib/.git/objects/pack
216Mi ./gnulib/.git/objects
218Mi ./gnulib/.git
274Mi ./gnulib
479Mi .
thanks,
Pádraig.
This bug report was last modified 1 year and 28 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.