How to get a variable to have the current dir path?

This question already has an answer here:

  • How to set a variable to the output of a command in Bash? 13 answers

  • When you want to set a variable, you don't use the $ :

    currentdir=`pwd`
    

    The $ is for when you want to do a variable substitution.


    Assigning to a variable is without the '$' sign. Using the value is with the '$' sign.

    currentdir=`pwd`
    

    try:

    currentdir=`pwd`
    

    (remove the $ )

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

    上一篇: 将MySQL“SELECT”查询传递给shell变量

    下一篇: 如何让变量具有当前目录路径?