#! /bin/ksh ## ## SCRIPT: duseanydir ## Where: in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea ## ######################################################################## ## PURPOSE: Shows the disk usage (in 1K blocks) in ALL subdirectories of ## a user-specified directory. ## ######################################################################## ## CALLED BY: feamain -> feautils.menu -> fileman.menu script ## ######################################################################## ## MAINTENANCE HISTORY: ## Written by: B. Montandon 2Sep1993 on aixa ## Updated by: B. Montandon 24Apr1995 for irix ## Updated by: B. Montandon 8May1997 Better .rhosts handling. ## Updated by: B. Montandon 5Mar1999 Chg report output from $HOME/temp.lis ## to $OUTLIST set by set_localoutlist; ## chgd handling local vs. nfs directory. ## Updated by: B. Montandon 13Oct1999 Set $FEDIR if null (for use in toolchest). ## Updated by: B. Montandon 13Mar2000 Right-justify dirsize numbers. ######################################################################## if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea export FEDIR fi # set -x ######################################################################## ## START OF PROMPTING LOOP, FOR DIRECTORY NAME. ######################################################################## # while true while : do ######################################################################## ## GET DIRECTORY NAME. ######################################################################## . $FEDIR/scripts/clearnns echo "${HIbold}\ ........................................................................... DiskUse-in-SubDirs: Show disk usage in ALL *SUB-DIRECTORIES* below a given directory known to `hostname` (largest subdirectory to smallest) ${HIreset} Enter a DIRECTORY NAME ... fully qualified or relative to current directory. ${HIbold} Examples: ${HIdim} your 'subs' CAE data:${HIreset} /data/subs/cae/$USER ${HIdim} your 'nuclear' CAE data:${HIreset} /data/nuclear/cae/$USER ${HIdim} your 'carrier' CAE data:${HIreset} /data/carrier/cae/$USER ${HIdim} your 'other' (DoubleEagle) CAE data:${HIreset} /data/other/cae/$USER ${HIdim} subs I-DEAS work & team data:${HIreset} /data/subs/ideas ${HIdim} nuclear I-DEAS work & team data:${HIreset} /data/nuclear/ideas ${HIdim} carrier I-DEAS work & team data:${HIreset} /data/carrier/ideas ${HIdim}other (DoubEagle) I-DEAS work&team data:${HIreset} /data/other/ideas ${HIdim} subs I-DEAS work (in-process) data:${HIreset} /data/subs/ideas/team/datamgmt# ${HIdim} subs I-DEAS team (check-in) data:${HIreset} /data/subs/ideas/team/shared# ${HIdim} Local work area:${HIreset} /local/scratch ${HIdim} Local $USER work area:${HIreset} /local/scratch/$USER ${HIdim} Local I-DEAS work area:${HIreset} /local/scratch/ideas ${HIdim} User preferences data:${HIreset} $HOME ${HIdim} parent of current directory:${HIreset} .. ${HIdim} current directory:${HIreset} . ${HIdim} WARNING: A summary of the /usr/people subdirectories, i.e. the user Home directories, may take many minutes. See nnsFEAmenu option 'u f uh' for a weekly Home-dirs report. ${HIreset} Current Directory: $PWD ${HIbold}\ (mouse-)Enter DIRECTORY NAME (or null to EXIT) ==>${HIreset} \c" read dirname1 if test "${dirname1}" = "" then break # exit fi if test ! -d "${dirname1}" then echo " ${dirname1} is not a directory. *** Press Enter to continue." read NNS_JUNK continue # exit fi if test "${dirname1}" = "/" then echo " Try a lower level directory than the root directory (/). *** Press Enter to continue." read NNS_JUNK continue # exit fi set -x cd ${dirname1} set - dirname1=`pwd` ######################################################################## ## Prep report HEADING on size of sub-directories. ######################################################################## . $FEDIR/scripts/set_localoutlist echo "\ .....................`date`............................ Disk usage (in 1K blocks) in ALL sub-directories of directory ${dirname1} Total usage is shown on first line. Disk usage (1K blks) Subdirectory name ------------- ------------------------ TerGigMegKil | | | |" > $OUTLIST ######################################################################## ## Get report data from an SGI server if the directory is NSF-mounted. ######################################################################## ## Old method of dealing with local vs. NFS directory: ## if test \("${dirname1}" = "/local" -o "${dirname1}" = "/local/scratch" \) LOCALCHK=`stat ${dirname1} | grep nfs` if test "$LOCALCHK" = "" then du -k ${dirname1} | awk '{printf ("%13s %s\n", $1, $2 )}' | \ sort +0 -1 -nr | fold -78 >> $OUTLIST else ######################################################################## ## Pop a message to the screen about what is going on, ## in the case of getting the data from remote server. ######################################################################## echo " ........................................................................... ${HIbold} !! GATHERING DATA. WAIT PLEASE ... ${HIreset} The following 'largest subdirectories' list is put in a report file named $OUTLIST It is then shown with a text-viewer (like 'pg') ... with an option to print. ${HIdim} An unsorted list is shown on screen. A sorted list -- biggest directories at the top -- is put in the report file. You are given an opportunity to browse and print the report file.${HIreset} " . $FEDIR/scripts/mak_rhosts ######################################################################## ## 'rsh' to server to do 'du'. ######################################################################## set -x # rsh sgia du -k $dirname1 | tee ${OUTLIST}_unsorted rsh engprd00 du -k $dirname1 | awk '{printf ("%13s %s\n", $1, $2 )}' | \ tee ${OUTLIST}_unsorted set - # . $FEDIR/scripts/mv_rhosts ######################################################################## ## SORT LOCALLY. ######################################################################## sort +0 -1 -nr ${OUTLIST}_unsorted | fold -78 >> $OUTLIST rm ${OUTLIST}_unsorted fi ######################################################################## ## Add TRAILER to report. ######################################################################## echo "\ ........................................................................ The output above was generated by the script $0 Uses commands like : du -k ${dirname1} | awk '{printf ( ... )}' | sort +0 -1 -nr This report can be generated via nnsFEAmenu option 'u f ud' (Utilities, File-tools, Used-by-subDirectories). Or it can be a drawer in the 'spacetools' command-utility, which you can implement as - a command alias, via your .profile file; - a desktop icon, via the 'Find, File QuickFind' tool drawers; - a drawer in the SGI toolchest, via your .auxchestrc file. ........................................................................ " >> $OUTLIST ######################################################################## ## SHOW REPORT, with option to print. ######################################################################## . $FEDIR/scripts/shofil $OUTLIST # set - ######################################################################## ## RETURN TO DIRECTORY PROMPT. ######################################################################## done ######################################################################## ## END OF prompting loop, for directory name. ########################################################################