问题描述
我正在尝试通过
sudo nano /etc/environment
该值是一个包含哈希的长字符串,#
。
The value is a long string containing a hash, #
.
包含#
时,字符串未完全存储; #
之后的字符都消失了。
With the #
included, the string is not stored fully; characters after the #
are gone.
如果不包括#
,
我试图将字符串包装在' "
:
I have tried to wrap the string in " "
:
MY_VARIABLE="34534554345 # DFGDGDFG"
我希望变量可以完全存储,像这样:
I expect the variable to be stored fully, like this:
34534554345#DFGDGDFG
不是这样的:
34534554345
推荐答案
PAM解释 / etc / environment
,而不是外壳。每行的意思是简单的 KEY = VALUE
,不需要引号。 #
标记为注释,无法将其转义。
PAM interprets /etc/environment
, not a shell. It's intended to be simple KEY=VALUE
on each line with no need for quotes. #
marks a comment and there is no way to escape it.
您可以使用 / etc / profile
来定义您的环境变量。
You can use /etc/profile
to define your environment variable. It should make it available system wide in most cases.
/ etc / environment
TEST2="12345#6789"
/ etc / profile
export TEST="12345 #6789"
结果:
root@tempmon:~ $ env|grep TEST
TEST=12345# 6789
TEST2=12345
这篇关于/ etc / environment中的哈希(“#”)符号导致字符串被拆分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!