LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 08-26-2018, 05:03 PM   #1
ampsys
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, 05:12 PM   #2
ampsys
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 07:22 PM. Reason: Removed bad language
 
Old 08-26-2018, 06:44 PM   #3
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Code:
du -sBG
per man du
Code:
-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.
 
  


Reply



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 08:37 AM
output time in ms from gettimeofday liqxpil Programming 3 04-23-2010 01:34 PM
how can I format/parse the output of time? luusac Linux - Newbie 4 04-09-2009 05:18 AM
Output ls one screen at a time anjanesh Linux - Newbie 10 01-03-2006 04:50 AM
output of time command! Valluvan Linux - Software 1 08-21-2003 06:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:27 AM.

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