macos 如何在 OS X 中使用终端向上移动目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3267504/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 07:04:01  来源:igfitidea点击:

How to move up a directory with Terminal in OS X

macosterminal

提问by DrANoel

When I launch a new Terminal window, it starts me in 'Macintosh HD/Users/MyName'. How can I back out of my user directory, back up to the top level?

当我启动一个新的终端窗口时,它会在“Macintosh HD/Users/MyName”中启动我。我怎样才能退出我的用户目录,回到顶层?

回答by davidcelis

cd ..will back the directory up by one. If you want to reach a folder in the parent directory, you can do something like cd ../foldername. You can use the ".." trick as many times as you want to back up through multiple parent directories. For example, cd ../../Applicationswould take you to Macintosh HD/Applications

cd ..将目录备份一。如果要访问父目录中的文件夹,可以执行类似cd ../foldername. 您可以多次使用“..”技巧,以通过多个父目录进行备份。例如,cd ../../Applications会带你去Macintosh HD/Applications

回答by JSON C11

Typing cdwill take you back to your home directory. Whereas typing cd ..will move you up only one directory (the direct parent of the current directory).

键入cd会将您带回主目录。而键入cd ..只会将您向上移动一个目录(当前目录的直接父目录)。

回答by D88naimi

For Mac Terminal

对于 Mac 终端

cd ..   # one up
cd ../  # two up
cd      # home directory 
cd /    # root directory
cd "yaya-13" # use quotes if the file name contains punctuation or spaces

回答by empedocle

To move up a directory, the quickest way would be to add an alias to ~/.bash_profile

要向上移动目录,最快的方法是向 ~/.bash_profile 添加别名

alias ..='cd ..'

and then one would need only to type '..[return]'.

然后只需要输入'..[return]'。

回答by Saral Kochar

Let's make it even more simple. Type the below after the $ sign to go up one directory:

让我们让它更简单。在 $ 符号后键入以下内容以上一级目录:

../