Linux – LANG=C is in a number of the /etc/init.d/* scripts. What does LANG=C do and why do you need to set LANG=C.

bashbootenvironment-variablesinitlinux

Its not clear what it does or what it contains. I tried greping the out put of set and env to see what C or LANG are set to in other places on the systems. Nothing was clear about how it is used or set. I don't even know what man page I should even start reading.

Any help here would be great as I try to decode the start up scripts on different Linux machines. If any one can recommend a good resources (books,documentation) that would help along this process That would be much appreciated.

Example of scripts using LANG=C on a centos6 machine

$ grep -i LANG=C ./*
./halt:LANG=C __umount_loop '$2 ~ /^\/$|^\/proc|^\/dev/{next}
./netconsole:   route=$(LANG=C ip -o route get to $host/32)
./netconsole:           arp=$(LANG=C /sbin/arping -c 1 -I $DEV $target 2>/dev/null | awk '/ reply from .*[.*]/ { print gensub(".* reply from .* \\[(.*)\\].*","\\1","G") }')
./netconsole:                   SYSLOGADDR=$(LANG=C host $SYSLOGADDR 2>/dev/null | awk '/has address / { print $NF }')
./network:          LANG=C sed -e "$__sed_discard_ignored_files" \
./network:          LANG=C sort -k 1,1 -k 2n | \
./network:          LANG=C sed 's/ //')
./network:              eval $(LANG=C fgrep "DEVICE=" ifcfg-$i)
./network:              eval $(LANG=C fgrep "TYPE=" ifcfg-$i)
./network:              eval $(LANG=C fgrep "SLAVE=" ifcfg-$i)
./network:              if LANG=C egrep -L "^ONBOOT=['\"]?[Nn][Oo]['\"]?" ifcfg-$i > /dev/null ; then
./network:            if ! LANG=C egrep -L "^ONBOOT=['\"]?[Nn][Oo]['\"]?" ifcfg-$i >/dev/null 2>&1 ; then
./network:              eval $(LANG=C fgrep "DEVICE=" ifcfg-$i)
./network:              eval $(LANG=C fgrep "TYPE=" ifcfg-$i)
./rpcbind:# We can't Japanese on normal console at boot time, so force LANG=C.
./rpcbind:        LANG=C

Example useage in scripts on a ubuntu 10.04 machine

$ grep -i LANG=C ./*
./apache2:ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"
./exim4:LANG=C
./ntop:export LANG=C\

Best Answer

It forces applications to use the default language for output, and forces sorting to be bytewise.

$ LANG=es_ES man
¿Qué página de manual desea?
$ LANG=C man
What manual page do you want?
$ LANG=en_US sort <<< $'a\nb\nA\nB'
a
A
b
B
$ LANG=C sort <<< $'a\nb\nA\nB'
A
B
a
b
Related Question