抄自catalina.sh
PRG="$0" # resolve links - $0 may be a softlink while [ -h "$PRG" ]; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`/"$link" fi done # 所执行程序所在的目录 PRGDIR=`dirname "$PRG"` # 所执行程序所在的目录的上级目录 [ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`