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]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux