Re: How to find total MB of a directory plus all subdirectories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 06, 2007 at 10:01:38PM +0100, Nigel Henry wrote:
> This is a silly question perhaps. I have my soundfiles in a directory named 
> Sounds Library, this contains many subdirectories, which contain the .wav 
> files.
> 
> What command can I use to find out the disk space this directory is taking up, 
> including all the files that are in the subdirectories?
> 
> Nigel.
> 

I wrote this a long time back for myself. It might suffice your needs.
Cut paste the following code in a file say: dirsize, chmod +x dirsize
and execute.

#-CUT & PASTE---------------------------------------------------------
#/bin/bash

IGNORE='proc /dev /sys /initrd /mnt /media'

# This script produces a list of dir size. Selects only MB and above entries.

# Arg is the dir name else pwd is selected
if [ -z "$1" ]; then
        SDIR=`pwd`
	OutPut=/tmp`pwd`
else
        SDIR=$1
	OutPut=/tmp/${USER}/${1}
fi

echo "Output file is ${OutPut}/dir-size.out"

mkdirhier ${OutPut} && ls -lAR --si --ignore="${IGNORE}" ${SDIR}|grep 'total' -B1|grep '^total[[:space:]][0-9\.]*[mMgG][[:space:]]*' -B1 >${OutPut}/dir-size.out 2>&1
echo -e "\nTotal Size Of Dir $SDIR" >>${OutPut}/dir-size.out 2>&1
du -ach ${SDIR}|grep "[[:space:]]total$" >>${OutPut}/dir-size.out 2>&1

less ${OutPut}/dir-size.out
#-CUT & PASTE---------------------------------------------------------
-- 
vikram...
         ||||||||
         ||||||||
^^'''''^^||root||^^^'''''''^^
        // \\   ))
       //(( \\// \\
      // /\\ ||   \\
     || / )) ((    \\
-- 
Machines take me by surprise with great frequency.
- Alan Turing
-- 
 *
~|~
 =
Registered Linux User #285795

[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux