Alfredo Braunstein wrote: >> Incidentaly, is there a more elegant (shell script) way to ascertain >> whether two directories are the same than: >> >> # If the "to" and the "from" files are in the same directory, >> # then we're done. >> PRESENT_DIR=`pwd` >> cd `dirname "$1"` >> FROM_DIR=`pwd` >> >> cd `dirname "$2"` >> TO_DIR=`pwd` >> >> cd $PRESENT_DIR >> test "$FROM_DIR" = "$TO_DIR" && exit 0 > > what about [ `dirname "$1"` -ef `dirname "$2"` ] ?
"test -e FOO" is a bash extension. Also, "dirname" does nothing more than strip everything after the final '/' character. "/foo/bar/../baz.cpp" and "/foo/baz.cpp" will appear to be in different directories. -- Angus