javaguy Posted May 26, 2008 Report Share Posted May 26, 2008 Is there a quick/easy command that a shell script can use to find the total size of the files in a directory? Quote Link to comment Share on other sites More sharing options...
ramfree17 Posted May 26, 2008 Report Share Posted May 26, 2008 play with the various options available to du (disk usage) and see if it fills your requirements. ciao! Quote Link to comment Share on other sites More sharing options...
AussieJohn Posted May 26, 2008 Report Share Posted May 26, 2008 (edited) 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. Edited May 26, 2008 by AussieJohn Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted May 26, 2008 Report Share Posted May 26, 2008 From the console I use: 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. Quote Link to comment Share on other sites More sharing options...
ac_dispatcher Posted May 27, 2008 Report Share Posted May 27, 2008 Ah yes the famous "ducks" command I read long ago in a book: du -cks * |sort -rn |head -n 11 Quote Link to comment Share on other sites More sharing options...
pmpatrick Posted May 27, 2008 Report Share Posted May 27, 2008 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: #!/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}" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.