Get path of where a script was called from

This question already has an answer here:

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

  • Try this:

    srcdir=$(pwd)
    

    which gets you the current directory. That is, where you are calling your script from, which should be Desktop something in your example.

    As duly discussed in the comments, this alternative is pretty good too:

    srcdir=$PWD
    
    链接地址: http://www.djcxy.com/p/9764.html

    上一篇: 我怎样才能写一个heredoc到Bash脚本中的文件?

    下一篇: 获取脚本被调用的路径