![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| to compare total directory structure and get sizes of all f on two different servers | mannam srinivas | Shell Programming and Scripting | 3 | 04-07-2008 05:21 AM |
| Script for checking and reporting file sizes in a directory. | marconi | Shell Programming and Scripting | 1 | 04-03-2008 09:00 AM |
| Help on optimization of the script | aju_kup | UNIX for Dummies Questions & Answers | 2 | 11-20-2007 02:21 AM |
| Loop through files in a directory | rladda | Shell Programming and Scripting | 4 | 06-24-2005 06:30 AM |
| Directory sizes | TRUEST | UNIX for Dummies Questions & Answers | 3 | 09-24-2003 10:24 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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. |
|
||||
|
So, it should look like this:
#!/usr/bin/ksh export MDIR=/datafiles NAME=$1 SERVER=$2 DIRECTORY=$3 DATABASE=$4 ID=$5 SIZE=`/usr/bin/ssh -q $ID@$SERVER find $DIRECTORY -type d -exec du -sk {} \;` echo $NAME $DATABASE $SIZE $DIRECTORY>> $MDIR/bldtuout.txt done When I try to run it, I get find: incomplete statement What am I doing wrong? |
|
||||
|
Thank you! That did it.
Two more questions: Now the output is all on one line, is there a quick way to parse it to multiple lines? When the find creates an error, it is written to the screen, is there a way to get it writen to an output file? Last edited by la_womn; 05-16-2008 at 06:43 PM.. |
|
||||
|
I figured it out. My script now looks like:
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|