如何在 Bash 中更改目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43471183/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change directory in Bash
提问by priyanka sharma
I am very new to scripting, can anybody tell how can I switch to directory in bash
.
我对脚本很陌生,谁能告诉我如何切换到bash
.
I have tried to do like this
我试过这样做
-bash-4.2$ cd /c
and cd c
but nothing works!
与cd c
但没有任何作品!
回答by Rahul
Check if you have any directories in your current path!
You can check that by ls -lrt
which lists the files and directories in your current path.
检查当前路径中是否有任何目录!您可以检查ls -lrt
which 列出了当前路径中的文件和目录。
If there are no directories, create one using mkdir c
and then do cd c
如果没有目录,请使用创建一个mkdir c
,然后执行cd c
Also you can navigate to your previous directory by using cd -
and your home directory by doing a cd ~
您也可以通过使用cd -
和您的主目录导航到您以前的目录cd ~