bash ~ 在 Unix Shell 脚本中是什么意思
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22126177/
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
What does ~ mean in Unix Shell Scripting
提问by Akash Sharma
I have UNIX server and When I access my shell using Putty.exe (for Windows)
我有 UNIX 服务器,当我使用 Putty.exe(适用于 Windows)访问我的 shell 时
I get Following PATH for public_html directory
我得到以下 PATH for public_html 目录
[email protected][~/public_html]#
I am excited to know that what does ~mean in above code
我很高兴知道~在上面的代码中是什么意思
Shell: BASH
外壳:BASH
回答by DonCallisto
Tilde (~
) indicates the home directory of the user
波浪号 ( ~
) 表示用户的家目录
So if you log in with root
user (for example) this means
因此,如果您使用root
用户登录(例如),这意味着
/root/public_html
If you log in with another user, let's say hsaka
, it is reasonable to think that this means
如果您使用其他用户登录,比方说hsaka
,可以合理地认为这意味着
/home/hsaka/public_html
回答by Devavrata
~is home directory and if you are rootthen it gives root directory.
~是主目录,如果您是根目录,则它会提供根目录。
回答by David H. Bennett
This is covered in the bash man page under 'Tilde Expansion'. Generally, it is analogous to using the $HOME environment variable. It is evaluated by the shell so you can use this in scripts that run under bash (or most other *nix shells). However, Tilde Expansion is not supported globally so its use in other applications may or may not work.
这在“波浪号扩展”下的 bash 手册页中有介绍。通常,它类似于使用 $HOME 环境变量。它由 shell 评估,因此您可以在 bash(或大多数其他 *nix shell)下运行的脚本中使用它。但是,波浪号扩展不受全球支持,因此它在其他应用程序中的使用可能有效,也可能无效。