Index | Thread | Search

From:
Stuart Henderson <stu@spacehopper.org>
Subject:
Re: dd commas
To:
Geoff Steckel <gwes@oat.com>
Cc:
tech@openbsd.org
Date:
Mon, 18 Nov 2024 20:51:14 +0000

Download raw body.

Thread
  • Tobias Heider:

    dd commas

    • Geoff Steckel:

      dd commas

      • Stuart Henderson:

        dd commas

      • enh:

        dd commas

On 2024/11/18 15:35, Geoff Steckel wrote:
> On 11/18/24 14:50, Tobias Heider wrote:
> > On Mon, Nov 18, 2024 at 01:36:55PM GMT, joshua stein wrote:
> > > Maybe someone else will find this useful, but when I ^T dd and see
> > > output like 1257557196800, I have to highlight three digits at a
> > > time in my terminal for my brain to understand if it's at hundreds
> > > of gigabytes or in terabytes.
> > I have often wished it was human readable by default and print a more
> > reasonable unit than Bytes, but this is definitely a step in the right
> > direction.
> > 
> > > Before:
> > > 
> > >      11994+0 records in
> > >      11993+0 records out
> > >      1257557196800 bytes transferred in 5017.398 secs (250659198 bytes/sec)
> > > 
> > > After:
> > > 
> > >      11994+0 records in
> > >      11993+0 records out
> > >      1,257,557,196,800 bytes transferred in 5017.398 secs (250,659,198 bytes/sec)
> > > 
> a) if this formatting is useful here, does it belong in a library?
> b) the final printout from dd has been the same for a long time
>    some scripts may depend on reading # bytes

Makes sense for SIGINFO imho. Not sure about the final display,
it does seem a bit of an awkward thing to be parsing, and it's not
consistent between dd implementations:

$ dd if=/dev/zero of=/dev/null count=500k
512000+0 records in
512000+0 records out
262144000 bytes transferred in 0.582 secs (450405362 bytes/sec)

$ gdd if=/dev/zero of=/dev/null count=500k
512000+0 records in
512000+0 records out
262144000 bytes (262 MB, 250 MiB) copied, 0.940789 s, 279 MB/s

> c) turning the commas on or off might wander into LC_ land
>    or adding a switch to dd

I don't think OpenBSD changes number formatting based on LC_