What does 'cd -' stand for?

后端 未结 8 1221
星月不相逢
星月不相逢 2020-12-13 05:41

In a bash shell script today I noticed the below command at the end of the script. I know what is cd but I am unaware of the significance of a dash after it.

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 05:55

    cd - brings you back to the last directory.

    $ cd ~/Desktop
    $ pwd
    /Users/daknok/Desktop
    $ cd /
    $ pwd
    /
    $ cd -
    $ pwd
    /Users/daknok/Desktop
    

提交回复
热议问题