Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-26-2018, 06:03 PM   #1
LQ Newbie
Registered: Jan 2014
Posts: 8

Rep: Reputation: Disabled
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?
Old 08-26-2018, 06:12 PM   #2
LQ Newbie
Registered: Jan 2014
Posts: 8

Original Poster
Rep: Reputation: Disabled
Figured it out:

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

Thanks for nothing, [removed]

Close this.

Last edited by rtmistler; 08-26-2018 at 08:22 PM. Reason: Removed bad language
Old 08-26-2018, 07:44 PM   #3
Senior Member
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.7.1908
Posts: 4,065

Rep: Reputation: 1383Reputation: 1383Reputation: 1383Reputation: 1383Reputation: 1383Reputation: 1383Reputation: 1383Reputation: 1383Reputation: 1383Reputation: 1383
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Just finished the last GCC compilation, please tell me if the following output is acceptable skorm513 Linux From Scratch 2 04-13-2016 09:37 AM
output time in ms from gettimeofday liqxpil Programming 3 04-23-2010 02:34 PM
how can I format/parse the output of time? luusac Linux - Newbie 4 04-09-2009 06:18 AM
Output ls one screen at a time anjanesh Linux - Newbie 10 01-03-2006 05:50 AM
output of time command! Valluvan Linux - Software 1 08-21-2003 07:45 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:18 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration