#! /bin/bash # # Programmer: Br. David Carlson # # Date: February 28, 2003 # # This is a helping script for the findfirst script. It finds the first file within # the directory given as the first parameter that matches the target given as # the second parameter. Output is to standard out and gives the full pathname # of the located file. An exit status of 0 is returned to indicate that a match # was found, otherwise an exit status of 1 is used. TMP=/tmp/findfirst.$$ OLDDIR="`pwd`" cd "$1" DIR="`pwd`" ls > $TMP sync while read fname do if [ -d "$fname" ] then # Recursive call of the script: findfirst.onedir "$fname" "$2" if [ $? -eq 0 ] then cd "$OLDDIR" exit 0 fi elif [ "$fname" = "$2" ] then echo "${DIR}/$fname" cd "$OLDDIR" exit 0 fi done < $TMP rm $TMP cd "$OLDDIR" exit 1