Estranho ordem de classificação, levando a resultados errados [fechado]

0

Pergunta

comm avisos classificados texto não está classificada e sort dá resultados errados. Por exemplo,

printf 'G.EC\nGE.BO\nGE.DA\n' | sort

saídas

GE.BOAB
G.ECH
GE.DAG

Outro exemplo é a saída de ls,

STATIONS_1800
stations.1800.txt
STATIONS.50d
STATIONS.D01
STATIONS.D16
stations.e2008.txt

o que deve ser

STATIONS_1800
STATIONS.50d
STATIONS.D01
STATIONS.D16
stations.1800.txt
stations.e2008.txt

A saída de env | grep 'LC\|LANG' é

LANGUAGE=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
LC_NAME=en_GB.UTF-8
LC_MONETARY=en_GB.UTF-8
LC_PAPER=en_GB.UTF-8
LANG=en_GB.UTF-8
LC_IDENTIFICATION=en_GB.UTF-8
LC_TELEPHONE=en_GB.UTF-8
LC_MEASUREMENT=en_GB.UTF-8
LC_TIME=en_GB.UTF-8
LC_COLLATE=en_GB.UTF-8
LC_NUMERIC=en_GB.UTF-8

Em outra máquina com o mesmo LC* e LANG*a classificação funciona perfeito.

bash shell sorting
2021-11-23 16:52:33
2

Melhor resposta

1

Conjunto LC_COLLATE=C

$ printf 'G.EC\nGE.BO\nGE.DA\n' | sort
GE.BO
G.EC
GE.DA

$ printf 'G.EC\nGE.BO\nGE.DA\n' | LC_COLLATE=C sort
G.EC
GE.BO
GE.DA
2021-11-23 17:19:18
1

A partir de man sort:

   ***  WARNING  ***  The locale specified by the environment affects sort order.  Set `LC_ALL=C` to get the traditional sort order that uses native byte values.
2021-11-23 17:25:42

Em outros idiomas

Esta página está em outros idiomas

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................