Get parent directory of shell script's directory

This question already has an answer here:

  • Getting the source directory of a Bash script from within 50 answers

  • 运行dirname两次(嵌套)。

    ~$ dirname $PWD
    /home
    ~$ dirname `dirname $PWD`
    /
    ~$ 
    

    I believe the answer is

    $(dirname $(dirname "$0"))
    

    don't forget about the double-quotes around "$0"

    链接地址: http://www.djcxy.com/p/9748.html

    上一篇: Cron:从shell脚本设置PATH不起作用

    下一篇: 获取shell脚本目录的父目录