如何回显从另一个位置执行的脚本的路径?

这个问题在这里已经有了答案:

  • 从50个答案中获取Bash脚本的源代码目录

  • 使用这个脚本。

    #!/bin/bash
    current_location=$(pwd)
    script_location=$(dirname $0)
    if [ $script_location= '.' ]
    then
     script_location="$current_location"
    fi
    echo $script_location
    
    链接地址: http://www.djcxy.com/p/9761.html

    上一篇: how to echo the path of the script executed from another location?

    下一篇: bash shell store path to current file as variable?