LinuxQuestions.org
Register a domain and help support LQ
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 01-09-2012, 03:40 PM   #1
Daravon
Member
 
Registered: Mar 2006
Posts: 170

Rep: Reputation: 15
du doesn't add up?


When I change to my website directory and run

Code:
du BKM/
I get the following output:
Code:
chaz@optimus:~/docs/tiWobs$ du BKM/
//a bunch of files and subdirectories
28352	BKM/
chaz@optimus:~/docs/tiWobs$

However when I paste this output into a spreadsheet, and add up all the sizes (leaving out the last line of course) I get some 54k and not 28k. Why the discrepancy? Which one is right?
 
Old 01-09-2012, 05:17 PM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,516

Rep: Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039
Try the "human" option to du:
Code:
du -hs dir
will only show a summary (in bytes, megabytes, gigabytes, etc.). Without an argument, du reports in blocks (see the manual page).

Hope this helps some.
 
Old 01-09-2012, 05:31 PM   #3
wpeckham
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 1,792

Rep: Reputation: 618Reputation: 618Reputation: 618Reputation: 618Reputation: 618Reputation: 618
to add to the above answer

Without the -s option, du will report the disk usage for every file AND FOLDER below the current level (default), or the parameters on the command line.

Since it reports the space a file takes, then also reports that space as part of the space taken by the folder HOLDING that file, the total of all those lines will ALWAYS add to more than the total space actually used. Adding the -s makes it report space used ONLY by the (s)ingle entities listed as parameters (or the current folder if you provide no parameters).

If the man page does not make it clear, there are online documents that describe these commands and options in finer detail. (Or, you can ask here.)
 
Old 01-09-2012, 05:35 PM   #4
Daravon
Member
 
Registered: Mar 2006
Posts: 170

Original Poster
Rep: Reputation: 15
Quote:
Since it reports the space a file takes, then also reports that space as part of the space taken by the folder HOLDING that file, the total of all those lines will ALWAYS add to more than the total space actually used.
Oh wow. Of course. I'm glad I asked this in the newbie forum...

Last edited by Daravon; 01-09-2012 at 05:47 PM.
 
  


Reply


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] chkconfig --add doesn't let me add x201s Linux - Newbie 2 03-14-2011 10:47 PM
df command output, doesn't add up? jrfk2 Linux - Newbie 5 07-13-2006 08:16 AM
add route doesn't work tkt Linux - Newbie 1 06-29-2005 06:56 PM
gMPlayer doesn't list the right vo drivers; how can I add them? DaneM Linux - Software 3 01-19-2005 07:28 AM
Why doesn't make install add a shortcut? Pontius Linux - Software 3 05-19-2004 05:59 AM


All times are GMT -5. The time now is 10:32 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration