shell 如何打印出当前脚本所在的目录
2023-10-15 本文已影响0人
for笑
其一:
current_path=$(dirname $(readlink -f $0))
echo ${current_path}
其二:
current_path=$(cd $(dirname $0);pwd)
echo ${current_path}
cd $(dirname $0) 表示切换到当前脚本所在的目录
其一:
current_path=$(dirname $(readlink -f $0))
echo ${current_path}
其二:
current_path=$(cd $(dirname $0);pwd)
echo ${current_path}
cd $(dirname $0) 表示切换到当前脚本所在的目录