bash 在bash中设置和导出多个环境变量为相同的值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22830128/
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
Set and export multiple environment variables to the same value in bash
提问by Hanxue
I would like to set the same value to the locale environment variables: LC_CTYPE
, LC_ALL
, LANG
.
我想为语言环境环境变量设置相同的值:LC_CTYPE
, LC_ALL
, LANG
.
I want to be able to set it directly on the interactive bash shell, something like this:
我希望能够直接在交互式 bash shell 上设置它,如下所示:
$ export LC_CTYPE=$LANG=$LC_ALL=C
This answer Assign same value to multiple variablesshows how to do it in a script, but not in the interactive shell.
这个答案为多个变量分配相同的值显示了如何在脚本中而不是在交互式 shell 中执行此操作。
采纳答案by devnull
The reference provided by you isn't a shell reference, it's a PHP example.
您提供的参考不是 shell 参考,而是一个 PHP 示例。
In shell, one way would be to use a loop:
在 shell 中,一种方法是使用循环:
for i in FOO BAR BAZ; do
export $i=value
done
回答by user3661170
export {LC_CTYPE,LANG,LC_ALL}=C