I like to disable all locale specific differences in shell scripts. What is the preferred way to do it?
LANG=C
or LC_ALL=C
locale
I like to disable all locale specific differences in shell scripts. What is the preferred way to do it?
LANG=C
or LC_ALL=C
Best Answer
LANG
sets the default locale, i.e. the locale used when no more specific setting (LC_COLLATE
,LC_NUMERIC
,LC_TIME
etc.) is provided; it doesn’t override any setting, it provides the base value.LC_ALL
on the other hand overrides all locale settings.Thus to override scripts’ settings, you should set
LC_ALL
.You can check the effects of your settings by running
locale
. It shows the calculated values, in quotes, for all locale categories which aren’t explicitly set; in your example,LANG
isn’t overridingLC_NUMERIC
, it’s providing the default value. IfLC_ALL
andLC_NUMERIC
aren’t set in the environment, the locale is taken fromLANG
, andlocale
shows that value forLC_NUMERIC
, as indicated by the quotes.See the
locales
manpage and the POSIX definitions of environment variables for details. See also How does the "locale" program work?