LinuxQuestions.org
Visit Jeremy's Blog.
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 04-03-2013, 01:59 AM   #1
Ajju1
LQ Newbie
 
Registered: Mar 2013
Posts: 2

Rep: Reputation: Disabled
wanted to check size of directory in linux/unix


Hi,
I wanted to check the Size of directory which contains 5 lakhs+ files
du -hsx working too slow..

Any other Option we have?

Thanks in adavance!
 
Old 04-03-2013, 02:47 AM   #2
kooru
Senior Member
 
Registered: Sep 2012
Posts: 1,385

Rep: Reputation: 273Reputation: 273Reputation: 273
Hi and welcome to LQ.
This thread could be useful
 
Old 04-03-2013, 03:18 AM   #3
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Do you want to check size of directory only or all files within it?

For directory only:
Code:
~$ du -sh /path/to/directory
For all files inside it (check size for each file):
Code:
~$ cd /path/to/directory
~$ du -sh ./*
 
Old 04-03-2013, 03:36 AM   #4
Ajju1
LQ Newbie
 
Registered: Mar 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
Unhappy

Thanx Koorru for referring the post...

so there is no command other than du -h,for getting instant result...
 
Old 04-03-2013, 04:43 AM   #5
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Speed of du depeends upon the size of the files as well as your file system hierarchy.

However, you can try following to check each and every file in your FS:
Code:
~# find / -exec du -sh '{}' \;
 
Old 04-03-2013, 05:09 AM   #6
gangadhar402
Member
 
Registered: Mar 2013
Location: the India
Distribution: Ubuntu,Debian and CentOS
Posts: 35

Rep: Reputation: 2
Hi,

see these threads these may helpful

http://www.codecoffee.com/tipsforlinux/articles/22.html

http://superuser.com/questions/16274...eir-subfolders

http://www.mkyong.com/linux/how-to-c...inux-solution/

Last edited by gangadhar402; 04-03-2013 at 05:17 AM.
 
Old 04-03-2013, 01:10 PM   #7
spearrule
LQ Newbie
 
Registered: Jun 2012
Posts: 1

Rep: Reputation: Disabled
Hi there.

Am I way off base suggesting something like:

Code:
ls -rsh /path/to/directory | grep "total"
Don't know if it will be any quicker though....
 
Old 04-03-2013, 01:59 PM   #8
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Originally Posted by spearrule View Post
Am I way off base suggesting something like:
Code:
ls -rsh /path/to/directory | grep "total"
Don't know if it will be any quicker though....
It can give you sizes, but only for files located in your current directory. Instead of this, use find command (as mentioned above), which will give you size of all files in file system, because find searches for files recursively.
Code:
root~# find / -exec du -sh '{}' \;
OR
user~$ sudo find / -exec du -sh '{}' \;

Last edited by shivaa; 04-03-2013 at 02:00 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
Linux/Unix Command to find RAM size? ssnkumar Linux - General 9 09-09-2009 10:38 AM
How to write crontab to check file size and all file in a directory? modpriest Linux - Newbie 1 02-14-2008 07:48 AM
Check Directory Size? Echo Kilo Linux - General 2 08-18-2005 07:53 AM


All times are GMT -5. The time now is 10:12 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