The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-16-2008
la_womn la_womn is offline
Registered User
 

Join Date: May 2007
Posts: 13
Directory sizes loop optimization

I have the following script:

#!/usr/bin/ksh

export MDIR=/datafiles

NAME=$1
SERVER=$2
DIRECTORY=$3
DATABASE=$4
ID=$5

export dirlist=`/usr/bin/ssh -q $ID@$SERVER find $DIRECTORY -type d -print`
for dir in $dirlist
do
SIZE=`</dev/null /usr/bin/ssh -q $ID@$SERVER du -ks $dir`
echo $NAME $DATABASE $SIZE $DIRECTORY>> $MDIR/bldtuout.txt
done


It is running forever, but does return the correct results. Is there a faster way? My goal is to have the directory sizes of all directories under a given path.
Reply With Quote
Forum Sponsor