获取当前shell脚本所在目录绝对路径
所属分类 shell
浏览量 683
dirOfShell=$(cd "$(dirname "$0")";pwd)
showdir.sh
echo "$0"
dirOfShell=$(dirname "$0")
echo "dirOfShell1=${dirOfShell}"
dirOfShell=$(cd "$(dirname "$0")";pwd)
echo "dirOfShell2=${dirOfShell}"
cd ~
dugang:~ dugang$ sh /Users/dugang/dugang/my/hellocode/web/shell/showdir.sh
/Users/dugang/dugang/my/hellocode/web/shell/showdir.sh
dirOfShell1=/Users/dugang/dugang/my/hellocode/web/shell
dirOfShell2=/Users/dugang/dugang/my/hellocode/web/shell
cd /Users/dugang/dugang/my/hellocode/web/shell/
./showdir.sh
./showdir.sh
dirOfShell1=.
dirOfShell2=/Users/dugang/dugang/my/hellocode/web/shell
上一篇
下一篇
构建工具sbt 简介
maven 和 sbt 命令对比
maven 与 sbt 配置对比
play框架简介
play REST hello 实例
一些面试知识点整理