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

Re: OT - Convert output of byte count to GB count?



Kent West wrote:
> The GNU dd command, when sent the -USR1 signal, pauses processing long
> enough to spit out a status line, like so:
> 
> 18335302+0 records in18335302+0 records out 9387674624 bytes (9.4 GB)
> copied, 34.6279 seconds, 271 MB/s
> ...
> 5605687296 bytes transferred in 1890.826832 secs (2964675 bytes/sec)
> ...
> Is there any thing I can throw at this command, perhaps a sed or awk
> command, etc, which would convert the status' bytes output to GB output?

1. Wouldn't it just be easier to use a Debian machine? :-)

2. If not that then I would compile a local copy of the GNU coreutils
dd command.  You don't need to install everything from coreutils.
Just copy the ./src/dd to /usr/local/bin/dd (or gnudd or whatever) and
then use it.

3. You could just convert that single number on the command line using
cut and paste.

  $ bc -ql
  5.22070312500000000000

  $ perl -le 'print 5605687296 / (1024*1024*1024)'
  5.220703125

  $ echo $((5605687296 / (1024*1024*1024) ))
  5

3. You could post process the output with a script.

  $ echo '5605687296 bytes transferred in 1890.826832 secs (2964675 bytes/sec)' | awk '{print $1/(1024*1024*1024)}'
  5.2207

4. See the brand new 'numfmt' command in the next GNU coreutils
release snapshot.  Of course if you can build numfmt from latest
sources then you are back to number 2 above where you would simply
build the dd from it.

  http://lists.gnu.org/archive/html/coreutils/2012-12/msg00087.html

  http://git.savannah.gnu.org/cgit/coreutils.git/tree/NEWS
  ** New programs
  numfmt: reformat numbers

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: