![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| 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 01:21 AM |
| Script for checking and reporting file sizes in a directory. | marconi | Shell Programming and Scripting | 1 | 04-03-2008 05:00 AM |
| Help on optimization of the script | aju_kup | UNIX for Dummies Questions & Answers | 2 | 11-19-2007 10:21 PM |
| Loop through files in a directory | rladda | Shell Programming and Scripting | 4 | 06-24-2005 02:30 AM |
| Directory sizes | TRUEST | UNIX for Dummies Questions & Answers | 3 | 09-24-2003 06:24 AM |
|
|
Submit Tools | LinkBack | Thread Tools | 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. |
| Forum Sponsor | ||
|
|
|
|||
|
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 02:43 PM. |
|
|||
|
I figured it out. My script now looks like:
Quote:
|
|||
| Google The UNIX and Linux Forums |