-   Linux - Newbie (
-   -   du Output in GB. EVERY TIME. -H not a acceptable (

ampsys 08-26-2018 06:03 PM

du Output in GB. EVERY TIME. -H not a acceptable
I need to measure directories by GIGABYTES because a monetary rate applies to them that way. du -ch or any variation of -h is NOT accetable because it jumps to TB or down to MB.

I want GB, every time so I can apply my rate.

What do?

ampsys 08-26-2018 06:12 PM

Figured it out:

du -sk | awk '{print $1/1024/1024}'

Thanks for nothing, [removed]

Close this.

scasey 08-26-2018 07:44 PM


du -sBG
per man du

-B, --block-size=SIZE
              scale sizes by SIZE before printing them; e.g., '-BM' prints sizes in units of 1,048,576 bytes; see SIZE format below
      Display values are in units of the first available SIZE from --block-size, and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.  Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).

      SIZE is an integer and optional unit (example: 10M is 10*1024*1024).  Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).

Which does essentially the same thing as the OP's solution with a single command and no rudeness.

All times are GMT -5. The time now is 01:24 AM.