Libervis Network - For a Free WorldLibervis Projects | Nuxified Projects
Welcome guest. Register | Login | Show what's new

Command for folder size?

Command for folder size?

What's the Linux command for determining folder size? I've never had to do that before. Note I don't mean "df -h" and "ls -al" only tells me the size of the folder's entry on the disk, not the contents as well.

__________________

When in doubt, follow the penguins.


My buddy (swell coworker from Brazil) wrote back:

You can use “du to check size on folder and subfolders.

There are some options as -–h and –-k for size format and –-s to summarize.

Please, be careful with folders where you have a large number of files. You may want to do CTRL+C if it takes too long on a production server.

__________________

When in doubt, follow the penguins.

I didn't know about the du command. Awesome, thanks for posting! Laughing out loud

__________________

Let's not fear freedom.

If you're looking for things to delete / move to an archive to make some space quickly (that is, not systematically, because you're in a hurry), try this:

du -a | sort -rn | less

Don't try it in / , but your home directory should be fine. It has saved me a few times when I was running out of quota.

__________________

CAN I HAS FIXD CAPSLOK KEE PLZ?

tbuitenh wrote:

If you're looking for things to delete / move to an archive to make some space quickly (that is, not systematically, because you're in a hurry), try this:

du -a | sort -rn | less

Don't try it in / , but your home directory should be fine. It has saved me a few times when I was running out of quota.

That is a righteous tip. Thanks! I used it just now on my home dir to check some things.

__________________

When in doubt, follow the penguins.

Or you could do this for an

Or you could do this for an awesome output Sticking out tongue

du -s directory/or/files | sort -rn | perl -e sizes | less

which gives output like:

  104.0000 kb rexima-1.4
  101.3994 mb tremulous-1.1.0-installer.x86.run
    1.1494 mb wrar37b3.exe
    1.1041 gb arch

the sizes perl script is:

#!/usr/bin/env perl

# Formats output of du.
#
# example: $ du -sc * | sort -n | perl -e sizes
#
# output:
#
#  104.0000 kb rexima-1.4
#  101.3994 mb tremulous-1.1.0-installer.x86.run
#    1.1494 mb wrar37b3.exe
#    1.1041 gb arch
#
# written by spyro_boy / 

use warnings;
use strict;
while(my $num=) {
 my $i=0;

 # add more, I'm too lazy to search up all the acronyms
 my @units = ("b","kb","mb","gb","tb");

 if(my @m=($num =~ m/^([0-9]+)\s+(.+)/)) {
  my $size=$m[0];
  do {
   $size = $size/1024;
   $i++;
  } while($size>1);
  $size = $size*1024;
  printf "%10.4f %s %s\n",$size,$units[$i],$m[1];
 }
}

I wrote it myself. Enjoy!

fsize

I wrote a Bash script to do this. You need this in your $PATH for it to work. It gives file sizes, not disk usage like du does.

__________________

Disclaimer: My posts may change (dramatically) within the first 15 minutes they're posted.

fail
a thing wrote:

I wrote a Bash script to do this. You need this in your $PATH for it to work. It gives file sizes, not disk usage like du does.

link fails. is there a mirror?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

We have 2328 members who wrote 2044 articles and 11847 comments. Welcome to our newest member, hutopire!

Who's online

There are currently 0 users and 9 guests online.
Nuxified RSS feed