#! /bin/ksh ## ## SCRIPT: compressun_1dir ## Where: in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea ## ######################################################################## ## PURPOSE: UN-compresses all files at one (the top) level in a directory, ## with '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 'compress_1fil' ## Updated by: B. Montandon O06 8Mar99 put file list to OUTLIST file ## instead of to screen ######################################################################## ## For testing: # set -x ######################################################################## ## START OF dirname prompting loop. ######################################################################## # while true while : do . $FEDIR/scripts/clearnns echo "${HIbold}\ .......................................................................... UN-COMPRESS *ALL FILES* at the top level of a chosen directory: ${HIreset} Uses command: ls | xargs -i uncompress /{} where each *.Z file in the directory will be uncompressed. Other files or sub- directories generate a 'no such file' message. ${HIdim} Changes each filename.Z to filename. (This utility will skip an uncompress if it finds a filename already exits. You can delete it, if that is OK, and try the UNcompress again.) ${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 ls ${dirname1} | xargs -i uncompress ${dirname1}/{} 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: ls ${dirname1} | xargs -i uncompress ${dirname1}/{} -------------------------------------------------------------------- " > $OUTLIST set -x ls -al ${dirname1} >> $OUTLIST set - . $FEDIR/scripts/shofil $OUTLIST fi done ######################################################################## ## END OF dirname prompting loop. ######################################################################## ## For testing: # set -