LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-05-2007, 01:11 PM   #1
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Rep: Reputation: 77
Viewing Folder Sizes?


Is there not an easy way in Linux CLI to view a folder and have it spit out the size of the directory and everything in it?

Lets say I have a folder called "data" and in this folder were many sub-folders and files that equal ~45GB's. If I run the "du -h /path/to/data, it will sit there for an hour sorting through all the folders and sub folders until it reaches the bottom and spits out the final tally for /path/to/data

Code:
 47GB      /path/to/data
I don't need to see a huge break down of the sub folders and everything else...I just want it to tell me how big "data" is beyond the generic 4k folder size you get with "ls -lh" command.

Thanks for any help!
 
Old 02-05-2007, 01:19 PM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
Well, it might sit there for an hour still, but du -sh /path/to/data will just show a summary...
 
Old 02-05-2007, 01:24 PM   #3
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
Yeah - it pretty much does the same thing as "du -h" without the verbose option of sorts. Still takes too long to get a result...
 
Old 02-05-2007, 01:30 PM   #4
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
Well if the folder is large even windows has to search the directory tree to give you the size of the folders contents. It does however do this faster somehow. Maybe you can email the Redmond guys and ask them how they do it :P
 
Old 02-05-2007, 01:33 PM   #5
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
I don't think that will go to far up the tree...
 
Old 02-05-2007, 01:37 PM   #6
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
hahah yea I think your right.
 
Old 02-05-2007, 01:49 PM   #7
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
Quote:
Originally Posted by exvor
Well if the folder is large even windows has to search the directory tree to give you the size of the folders contents. It does however do this faster somehow.
I don't know that I would say it was any faster. He's talking about an awful lot of data...
 
Old 02-05-2007, 09:35 PM   #8
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
Yeah but the annoyance is that in Windows XP, I can right click a folder and select properties and see the size of the folder or you can just view "list view" and it list everything next to each folder almost instantly regardless of the size.

So far in Linux, I don't see this being possible without Linux having to list or scan through every single file which can take hours.
 
Old 02-06-2007, 02:27 AM   #9
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
It's not the OS that determines this speed. It's more the filesystem and it's implementation.
If you have a lot (ie thousands) of very small files, all filesystems are slow and directory sizes will be too...

Windows isn't that fast either. Otherwise, people wouldn't have written special tools to calculate directory sizes.
In explorer, if you select all items in a folder, you immediately get the total size on the left, but that doesn't include the contents of directories (recursively). That's why it's much faster.
It's only when you right-click, select properties of a folder that you get total size, which is calculated rather slowly (you can see it increment bit by bit).
 
Old 02-06-2007, 03:18 AM   #10
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
I find useful the following code to compute size of a directory as the sum of the size of every single file:
Code:
ls -lR /path/to/dir | gawk '{size+=$5} END {print size}'
on my linux box is faster than du!
 
Old 02-06-2007, 05:41 AM   #11
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
There are graphical apps to do this also
baobab for gnome
xdiskusage for X
konqueror for kde
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Declaring Folder Sizes for Apache makeshifttheory Ubuntu 3 06-04-2006 06:36 PM
Folder Max Size and Limiting SSH access to home folder. Mefistofeles Linux - General 4 11-26-2005 02:09 PM
Folder permissions viewing in Suse 9.1 randon SUSE / openSUSE 2 02-23-2005 11:31 PM
How does one calculate folder sizes in linux GryphonTech Linux - Newbie 2 10-23-2004 03:50 PM
how can i default the max folder file size when it create inside a folder antony_csf Linux - Software 1 06-17-2004 02:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:22 PM.

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