1#!/bin/sh 2UP= 3DN=${PWD:?} 4TP=${TOPDIR:?} 5 6while [ ! $TP/$UP/. -ef $DN ] ;do 7 UP=`basename $PWD`/$UP 8 cd .. 9 if [ "$PWD" = "/" ]; then echo "Lost"; exit 1; fi 10done 11 12echo $UP 13exit 0 14