文章目录shell的dirname $0 shell的dirname $0 dirname_test.sh #!/bin/bash path=$(cd dirname $0;pwd) echo pathpath2=path path2=pathpath2=(dirname $0) echo $path2 sh dirname_test.sh /home/ltc . dirname $0 只是获取的当前脚本的相对路径. cd dirname $0;pwd 先cd到当前路径然后pwd,打印成绝对路径 来源:CSDN作者:LTC_1234链接:https://blog.csdn.net/LTC_1234/article/details/104264909 标签 ltc