Index: mttroot/mtt/bin/mtt_find ================================================================== --- mttroot/mtt/bin/mtt_find +++ mttroot/mtt/bin/mtt_find @@ -12,10 +12,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.4 1998/07/16 20:40:24 peterg +## Cleaned up algorithms +## ## Revision 1.3 1998/07/16 09:15:34 peterg ## Now prints: ## dir ## name_lbl.txt ## access time @@ -26,37 +29,59 @@ ## Revision 1.1 1996/11/10 10:48:45 peterg ## Initial revision ## ############################################################### -path="$1" +# Set up dummy file +rm -f mtt_junk +touch mtt_junk +# Interpret the arguments +path="$1" if [ -n "$2" ]; then - name="-name $2" + name=`basename $2` + longname=$2 + Name="-name $name" fi -q=\ +# Find all dirs in path with same name as component +# AND the path contains the full (name+library) name paths=`echo $path | tr ":" " "` foundpath=`\ for thepath in $paths; do - find $thepath -type d $name -print -done | \ -sort -u` + find $thepath -type d $Name -print +done |\ +sort -u |\ +grep "$longname"` # If non-null result, check that the name_lbl.txt file exists in dir name # and print dirname and file name and last access time if [ -n "$foundpath" ]; then for thepath in $foundpath ; do dirname=`echo $thepath | awk -F/ '{print $NF}'` fullname="$dirname"_lbl.txt find $thepath -maxdepth 1 -name $fullname -printf '%h\t%f\t%Ac\n'; - done + done |\ + tee mtt_junk fi +# Check exit status and return +hits=`wc mtt_junk | awk '{print $1}'` +rm -f mtt_junk + +if [ $hits = "1" ]; then + exit 0 +elif [ $hits = "0" ]; then + exit 1 +elif [ $hits > "1" ]; then + exit 2 +else + exit 3 +fi