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 Sun, Mar 18, 2007 at 01:44:10PM +0530, Vikram Goyal wrote:

Please update the code, if you chose to use it. It'll run with spaces in
names also, just needed to quote...

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

IGNORE='proc /dev /initrd /mnt'

# 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||^^^'''''''^^
        // \\   ))
       //(( \\// \\
      // /\\ ||   \\
     || / )) ((    \\
-- 
today, n.:
	A nice place to visit, but you can't stay here for long.
-- 
 o
~|~
 =
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