Lc_all = C

Source: Internet
Author: User
Tags locale setting posix
在很多的shell脚本中,我们经常会看见某一句命令的前面有一句“LC_ALL=C”SAR_CMD="LC_ALL=C sar -u -b 1 5 | grep -i average "这到底是什么意思?LC_ALL=C 是为了去除所有本地化的设置,让命令能正确执行。---------------------------------转帖:

在Linux中通过locale来设置程序运行的不同语言环境,locale由ANSI C提供支持。locale的命名规则为<语言>_<地区>.<字符集编码>,如zh_CN.UTF-8,zh代表中文,CN代表大陆地区,UTF-8表示字符集。在locale环境中,有一组变量,代表国际化环境中的不同设置:1.    LC_COLLATE

2.    LC_CTYPE



5.    LC_TIME


7.    LANG
LC_*的默认值,是最低级别的设置,如果LC_*没有设置,则使用该值。类似于 LC_ALL。

8.    LC_ALL


"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?# localeHow 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
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
How to change the locale by setting the system default locale?
LANG=CLC_ALL=CExample 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=CLC_ALL=CNote: 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 anyoptions:# localeLANG=CLC_CTYPE= "C"LC_NUMERIC= "C"LC_TIME= "C"LC_COLLATE= "C"LC_MONETARY= "C"LC_MESSAGES= "C"LC_ALL=C


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.