Help - Search - Members - Calendar
Full Version: Directory size?
MandrivaUsers.org > Advanced Topics > Command Line, Kernel and Programming
javaguy
Is there a quick/easy command that a shell script can use to find the total size of the files in a directory?

ramfree17
play with the various options available to du (disk usage) and see if it fills your requirements.

ciao!
AussieJohn
Try .....filelight.... excellent visual presentation and in depth detail of file sizes. Also shows percentages. Invaluable.

I always install it, and have done for years.

Cheers. John.
ianw1974
From the console I use:

CODE
du -sh `ls`


for example, if I was in /home/username at the time, I would see the total size for Documents, Downloads, Music, etc, etc. The -sh for du command gives summary and human readable format of directory sizes from the directory listing provided by the command ls. The single angled quote is important.
ac_dispatcher
Ah yes the famous "ducks" command I read long ago in a book:

CODE
du -cks * |sort -rn |head -n 11

pmpatrick
Here's a bash script I either wrote or picked up somewhere a long time ago that will give the directory size in bytes of the current directory:

CODE
#!/bin/bash

## Script gives size of current directory in Bytes when executed

let TotalBytes=0

for Bytes in $(ls -laR | grep "^-" | awk '{ print $5 }')
do
   let TotalBytes=$TotalBytes+$Bytes
done

echo  "${TotalBytes}"
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.