#! /bin/ksh ## ## SCRIPT: compressun_dir_all_levs ## Where: in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea ## ######################################################################## ## PURPOSE: UN-compresses all files at ALL LEVELS under a directory, ## with ' find -name "*.Z" -exec uncompress {} \; '. ## ## Includes a prompting loop with a text-based ## (non-GUI) Directory-Navigator. (to be replaced by ## a Tk GUI.) ######################################################################## ## CALLED BY: feamain -> feautils.menu -> fileman.menu script ## ######################################################################## ## MAINTENANCE HISTORY: ## Written by: B. Montandon O06 5Mar99 based on 'compressun_1dir' ## Updated by: B. Montandon O06 8Mar99 put file list to OUTLIST file ## instead of to screen ######################################################################## ## For testing: # set -x ######################################################################## ## START OF filename prompting loop. ######################################################################## # while true while : do . $FEDIR/scripts/clearnns echo "${HIbold}\ .......................................................................... UN-COMPRESS *ALL FILES* at *ALL LEVELS* under a chosen directory: ${HIreset} Uses command: find -name "*.Z" -exec uncompress {} \; where *.Z represents all the compressed files at all levels under the directory . ${HIdim} Changes each filename.Z to filename. ${HIbold} NOTE: You can use nnsFEAmenu option 'u f ud' (Utilities, File-tools, Used-space-by-sub-Directories) BEFORE & AFTER running this un-compress --- to see the change in space-used. ${HIreset} Navigate to your directory using Directory-Navigator." . $FEDIR/scripts/set_dirname if test "${dirname1}" = "" then break # exit fi ################################################## ## Check to see if name is indeed a directory. ################################################## if test ! -d "${dirname1}" then echo " ${dirname1} is not a directory. Try again. *** Press Enter to continue." read NNS_JUNK continue # break fi ################################################## ## Check to see if user owns the directory. ################################################## DIROWNER=`ls -ld ${dirname1} | awk '{print $3}'` if test ! "$DIROWNER" = "$USER" then echo " You do not own $DIR Try again. *** Press Enter to continue." read NNS_JUNK continue # break fi ################################################## ## Check to see if this is the directory that the ## user wants to use. ################################################## echo "${HIbold} ...................................................................... Is ${HIreset} $dirname1 ${HIbold} the directory whose files you want to UNcompress? n or y Default = n ==>${HIreset} \c" read dir_ok if test "${dir_ok}" = "" then dir_ok="n" fi dir_ok=`echo "$dir_ok" | tr "[A-Z]" "[a-z]"` if test "${dir_ok}" = "n" then # break continue else echo " " ################################################## ## HERE IS THE UN-COMPRESS COMMAND IMPLEMENTATION. ################################################## set -x find ${dirname1} -name "*.Z" -exec uncompress {} \; set - echo " *** Done UN-compressing. Press Enter to continue." read NNS_JUNK ################################################## ## Prep output to show all files compressed. ################################################## . $FEDIR/scripts/set_localoutlist echo " ............... `date` ......................... List of sub-directories & files AFTER UNCOMPRESS command: find ${dirname1} -name "*.Z" -exec uncompress {} \; -------------------------------------------------------------------- " > $OUTLIST ######################################################################## ## Get report data from 'sgia' if the directory is NSF-mounted. ######################################################################## NFSCHECK=`stat ${dirname1} | grep nfs` if test "$NFSCHECK" = "" then set -x ls -alR ${dirname1} >> $OUTLIST set - else . $FEDIR/scripts/mak_rhosts set -x rsh sgia ls -alR ${dirname1} >> $OUTLIST set - # . $FEDIR/scripts/mv_rhosts fi . $FEDIR/scripts/shofil $OUTLIST fi done ######################################################################## ## END OF dirname prompting loop. ######################################################################## ## For testing: # set -