Results 1 to 4 of 4
hi,
again in trouble..
how can i get the directory size in bytes in 'c' Language on linux?????
the directory may contain files or subfolders...
i think the dirent.h file ...
- 09-06-2004 #1Just Joined!
- Join Date
- Sep 2004
- Posts
- 21
How to find Directory Size ?
hi,
again in trouble..
how can i get the directory size in bytes in 'c' Language on linux?????
the directory may contain files or subfolders...
i think the dirent.h file has to be included..
but i dont know about wat function shoud i use to get the directory size in bytes...
Help ME Out.........URGENT!
- 09-06-2004 #2
You need to use the du command. not sure if u need to be root to use this, but if it fails as a standard user su and give it a go as root. tho u may wanna check out the man pages for it to see what tags to ass to make it show the size in megabytes rather than bytes!
edit: I have just gone back to linux to find the flag u want to use
If u type:
this will disply the disk usage of the current folder in human readable format (megabytes etc.Code:du -h
"I am not an alcoholic, alcoholics go to meetings"
Registered Linux user = #372327
- 01-14-2007 #3Just Joined!
- Join Date
- Jan 2007
- Posts
- 12
Or if you don't wanna see all of the sub-directories you can expand on this by typing...
Code:du -h | grep -v '/' | awk '{print $1}'
- 01-25-2010 #4Just Joined!
- Join Date
- Jan 2010
- Posts
- 1
This is much faster if you want only the total size.
Code:du -h | tail -n 1



