在bash中设置和导出多个环境变量为相同的值(Set and export multiple environment variables to the same value in bash)

编程入门 行业动态 更新时间:2024-10-12 12:27:13
在bash中设置和导出多个环境变量为相同的值(Set and export multiple environment variables to the same value in bash)

我想为区域设置环境变量设置相同的值: LC_CTYPE , LC_ALL , LANG 。

我希望能够直接在交互式bash shell中设置它,如下所示:

$ export LC_CTYPE=$LANG=$LC_ALL=C

此答案将相同的值分配给多个变量显示如何在脚本中执行此操作,但不在交互式shell中。

I would like to set the same value to the locale environment variables: LC_CTYPE, LC_ALL, LANG.

I want to be able to set it directly on the interactive bash shell, something like this:

$ export LC_CTYPE=$LANG=$LC_ALL=C

This answer Assign same value to multiple variables shows how to do it in a script, but not in the interactive shell.

最满意答案

您提供的参考不是shell参考,它是一个PHP示例。

在shell中,一种方法是使用循环:

for i in FOO BAR BAZ; do export $i=value done

The reference provided by you isn't a shell reference, it's a PHP example.

In shell, one way would be to use a loop:

for i in FOO BAR BAZ; do export $i=value done

更多推荐

本文发布于:2023-04-29 02:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1334462.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   环境变量   Set   bash   environment

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!