Check if in right directory on Linux

cd $MY_DIR

if [ `pwd` != "$MY_DIR" ] # or if [ "$PWD" != "$MY_DIR" ]
# Not in the right directory
then
echo "Can't change to $MY_DIR."
exit $E_XCD #E_XCD=86
fi

Comments