本文共 636 字,大约阅读时间需要 2 分钟。
bash 获取环境变量
In Bash, ~username
gives the username
user’s home. However, this does not work for situations where username
is in a variable such as
在Bash中, ~username
给出username
用户的家。 但是,这不适用于username
位于变量(例如)中的情况
~$user
How to get the home directory from the in a variable in Bash?
如何从Bash中的变量中的获取主目录?
You can use this Bash snippet:
您可以使用以下Bash 片段:
userhome=$(eval echo ~$user)
Here, $user
get evaluated to its value (say VALUE) and then ~VALUE
will be evaluated again by eval
which gives the same effect as ~username
.
在这里, $user
得到评估它的价值(VALUE说),然后~VALUE
将再次评估eval
这给同样的效果~username
。
翻译自:
bash 获取环境变量
转载地址:http://pqlwd.baihongyu.com/