创客百科

姿势共享,有节操无门槛参与的创客百科,创客动力之源 \ (^_^) /

用户工具

站点工具


note:spoony:export-lc_all-c

这是本文档旧的修订版!


A PCRE internal error occured. This might be caused by a faulty plugin

====== export LC_ALL=C ====== 解决pip install 时locale.Error: unsupported locale setting <code> 在很多的shell脚本中,我们经常会看见某一句命令的前面有一句“LC_ALL=C” SAR_CMD="LC_ALL=C sar -u -b 1 5 | grep -i average " 这到底是什么意思? LC_ALL=C 是为了去除所有本地化的设置,让命令能正确执行。 --------------------------------- 转帖:http://www.linuxsky.org/doc/newbie/200707/84.html 在Linux中通过locale来设置程序运行的不同语言环境,locale由ANSI C提供支持。locale的命名规则为<</span>语言>_<</span>地区>.<</span>字符集编码>,如zh_CN.UTF-8,zh代表中文,CN代表大陆地区,UTF-8表示字符集。在locale环境中,有一组变量,代表国际化环境中的不同设置:1. LC_COLLATE 定义该环境的排序和比较规则 2. LC_CTYPE 用于字符分类和字符串处理,控制所有字符的处理方式,包括字符编码,字符是单字节还是多字节,如何打印等。是最重要的一个环境变量。 3. LC_MONETARY 货币格式 4. LC_NUMERIC 非货币的数字显示格式 5. LC_TIME 时间和日期格式 6. LC_MESSAGES 提示信息的语言。另外还有一个LANGUAGE参数,它与LC_MESSAGES相似,但如果该参数一旦设置,则LC_MESSAGES参数就会失效。LANGUAGE参数可同时设置多种语言信息,如LANGUANE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"。 7. LANG LC_*的默认值,是最低级别的设置,如果LC_*没有设置,则使用该值。类似于 LC_ALL。 8. LC_ALL 它是一个宏,如果该值设置了,则该值会覆盖所有LC_*的设置值。注意,LANG的值不受该宏影响。 C"是系统默认的locale,"POSIX"是"C"的别名。所以当我们新安装完一个系统时,默认的locale就是C或POSIX。 "POSIX" :Specifies the minimal environment for C-language translation called the POSIX locale. If setlocale() is not invoked, the POSIX locale is the default "C" Equivalent to "POSIX". ----------------------------------- How to view the current locale setting? # locale How to change the locale setting? * Via the CDE login locale * As a user-specific locale * As a system default locale To change the current locale setting, first confirm that the desired locale is installed on the system with: # locale -a de en_AU en_CA en_UK C If the desired locale is not in the list, you will need to install the appropriate packages for that locale. See the Note below for more information about locale packages. How to change the locale via the CDE login locale? On the CDE login banner: Choose options - languages Under languages - choose the new locale The CDE banner will re-cycle and then you can login to the selected locale. NOTE: If a user has a different default locale set in their environment, the that locale setting will override the selected CDE login locale. How to set a user-specific locale? Note: For sh, ksh: # LANG=C; export LANG # LC_ALL=C; export LC_ALL For csh: # setenv LANG C # setenv LC_ALL C Note: To set a default locale for a user's environment, set the LANG or LC_* variables in a user's shell intialization file such as $HOME/.profile or $HOME/.cshrc How to change the locale by setting the system default locale? LANG=C LC_ALL=C Example from the /etc/default/init file: # Lines of this file should be of the form VAR=value, where VAR is one of # TZ, LANG, or any of the LC_* environment variables. LANG=C LC_ALL=C Note: The system must be rebooted after making changes to the /etc/default/init file in order for the changes to take effect. How to verify the locale setting? After setting or changing the locale, verify that the locale is set correctly: Check if the locale is set correctly by running the locale command without any options: # locale LANG=C LC_CTYPE= "C" LC_NUMERIC= "C" LC_TIME= "C" LC_COLLATE= "C" LC_MONETARY= "C" LC_MESSAGES= "C" LC_ALL=C root@ubuntu:~# locale locale: Cannot set LC_ALL to default locale: No such file or directory LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="en_US.UTF-8" LC_NUMERIC=zh_CN.UTF-8 LC_TIME=zh_CN.UTF-8 LC_COLLATE="en_US.UTF-8" LC_MONETARY=zh_CN.UTF-8 LC_MESSAGES="en_US.UTF-8" LC_PAPER=zh_CN.UTF-8 LC_NAME=zh_CN.UTF-8 LC_ADDRESS=zh_CN.UTF-8 LC_TELEPHONE=zh_CN.UTF-8 LC_MEASUREMENT=zh_CN.UTF-8 LC_IDENTIFICATION=zh_CN.UTF-8 LC_ALL= root@ubuntu:~# export LC_ALL=C root@ubuntu:~# locale LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="C" LC_NUMERIC="C" LC_TIME="C" LC_COLLATE="C" LC_MONETARY="C" LC_MESSAGES="C" LC_PAPER="C" LC_NAME="C" LC_ADDRESS="C" LC_TELEPHONE="C" LC_MEASUREMENT="C" LC_IDENTIFICATION="C" LC_ALL=C </code>

本页面的其他翻译:
note/spoony/export-lc_all-c.1485328070.txt.gz · 最后更改: 2017/01/25 15:07 由 127.0.0.1