Save current directory in variable using Bash?

后端 未结 9 662
时光说笑
时光说笑 2020-12-07 15:34

What I\'m trying to do is find the current working directory and save it into a variable, so that I can run export PATH=$PATH:currentdir+somethingelse. I\'m not

9条回答
  •  失恋的感觉
    2020-12-07 15:46

    for a relative answer, use .

    test with:

    $ myDir=.
    $ ls $myDir
    $ cd /
    $ ls $myDir
    

    The first ls will show you everything in the current directory, the second will show you everything in the root directory (/).

提交回复
热议问题