# 在某些情况下会拿到错误结果 work_path=$(dirname $0) work_path=$(pwd)## 正确实现 # 通过 readlink 获取绝对路径,再取出目录 work_path=$(dirname $(readlink -f $0))# 或者曲线救国 work_path=$(dirname $0) cd ./${work_path} # 当前位置跳到脚本位置 work_path=$(pwd) # 取到脚本目录 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏
此处评论已关闭