#! /bin/ksh ## ## SCRIPT: compress_1dir ## Where: in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea ## ######################################################################## ## PURPOSE: Compresses all files at one (the top) level in a directory, ## with 'compress /*'. ## ## 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}\ .......................................................................... COMPRESS *ALL FILES* at the top level of a chosen directory: ${HIreset} Uses command: ls | xargs -i compress /{} where each filename in is converted to a compressed file named filename.Z -- if it is not a directory, has no .Z file already, and is not empty. Sub-directories generate 'not a regular file' messages. (This utility will skip a compress if it finds a filename.Z already exits. You can delete it, if that is OK, and try the compress again.) ${HIbold} NOTE: You can use nnsFEAmenu option 'u f ud' (Utilities, File-tools, Used-space-by-sub-Directories) BEFORE & AFTER running this 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 COMPRESS? 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 COMPRESS COMMAND IMPLEMENTATION. ################################################## set -x ls ${dirname1} | xargs -i compress ${dirname1}/{} set - echo " *** Done 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 COMPRESS command: ls ${dirname1} | xargs -i compress ${dirname1}/{} -------------------------------------------------------------------- " > $OUTLIST set -x ls -al ${dirname1} >> $OUTLIST set - . $FEDIR/scripts/shofil $OUTLIST fi done ######################################################################## ## END OF dirname prompting loop. ######################################################################## ## For testing: # set -