LC_ALL=C的含義

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   io   os   使用   ar   

在很多的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的命名規則為<語言>_<地區>.<字元集編碼>,如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?# 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
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=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

LC_ALL=C的含義

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.