The Computer Oracle

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.

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Darkness Approaches Looping

--

Chapters
00:00 Lang=C Is In A Number Of The /Etc/Init.D/* Scripts. What Does Lang=C Do And Why Do You Need To Set L
01:35 Answer 1 Score 4
01:51 Accepted Answer Score 18
02:07 Answer 3 Score 7
02:44 Thank you

--

Full question
https://superuser.com/questions/334800/l...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #bash #boot #environmentvariables #init

#avk47



ACCEPTED ANSWER

Score 18


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



ANSWER 2

Score 7


As already explained, the LANG environment variable controls localization.

It affects many standard command-line tools like sort, grep, awk.

Setting its value to "C" tells all those tools to consider only basic ASCII characters and disable UTF-8 multibyte match.

Another good reason than localisation to use that environment variable is performance: it can make grep 1000 times faster for grep versions < 2.7 : http://rg03.wordpress.com/2009/09/09/gnu-grep-is-slow-on-utf-8/

On the reason why the letter "C" is used to specify a "safe" basic locale, see Why "LANG=C"? (not D or E or F).




ANSWER 3

Score 4


LANG=C is a way to disable localization. It's used in scripts to predict program output which may vary based on current language. For more information read this