是否可以找到当前在KornShell(ksh)中执行的脚本的完整路径?
即如果我的脚本在/opt/scripts/myscript.ksh中,我可以在该脚本中以编程方式发现/opt/scripts/myscript.ksh?
谢谢,
你可以使用:
原文链接:https://www.f2er.com/bash/388069.html## __SCRIPTNAME - name of the script without the path ## typeset -r __SCRIPTNAME="${0##*/}" ## __SCRIPTDIR - path of the script (as entered by the user!) ## __SCRIPTDIR="${0%/*}" ## __REAL_SCRIPTDIR - path of the script (real path,maybe a link) ## __REAL_SCRIPTDIR=$( cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P )