#! /bin/bash
PRG="$0"
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")
# full path
cd "$PRGDIR"/
PRGDIR=$(pwd)
echo "$PRGDIR"
网友评论