Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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!

  2. #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:
    Code:
    du -h
    this will disply the disk usage of the current folder in human readable format (megabytes etc.
    "I am not an alcoholic, alcoholics go to meetings"
    Registered Linux user = #372327

  3. #3
    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}'

  4. $spacer_open
    $spacer_close
  5. #4
    -->
    This is much faster if you want only the total size.
    Code:
    du -h | tail -n 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •