A log-analysis script needs English messages and simple byte-order sorting regardless of the user's locale.
No LC_ALL or individual LC_* values are set.
Which setting is appropriate?
When no LC_* or LC_ALL values are set, LANG=C supplies the portable C-locale defaults for messages and collation.
Detailed explanation
LANG=ja_JP.UTF-8Incorrect. This selects Japanese locale rules.
Incorrect. This selects Japanese locale rules.
LANG=CCorrect. LANG=C fixes the default categories to the C locale.
Correct. LANG=C fixes the default categories to the C locale.
LC_TIME=CIncorrect. It changes only the time category.
Incorrect. It changes only the time category.
TZ=CIncorrect. TZ selects a time zone, not locale behavior.
Incorrect. TZ selects a time zone, not locale behavior.
Try it yourself
An example you can run in a temporary verification environment.
LANG=C locale | sed -n '1,6p'Expected result
各未指定カテゴリがCとして評価される表示Key points
- LANG is the default
- C is portable
- LC_ALL and LC_* override it
Notes
- Environment: POSIX locale / 子プロセス環境だけ変更
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.