I'm having problem with sort -g
(i.e. general numeric sort) command when run via ssh. Example correct run on a file with 4 lines:
sort -g foo
9.1e-02
0.1
0.5
10.
cat foo
0.5
0.1
9.1e-02
10.
I've recently installed Ubuntu 20.04 and I'm using the default terminal. When I ssh from that terminal to the same machine as used above, then I get incorrect result:
sort -g foo
0.1
0.5
9.1e-02
10.
It seems like some error caused by the terminal from which I ssh. I've tried to find an option in Preferences, but haven't found anything that seemed related. Please let me know what other info I should add.
Edit 1
locale
for well-working system and terminal:
LANG=en_US.UTF-8
LC_CTYPE=pl_PL
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE=POSIX
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
for the one with bug:
LANG=en_US.UTF-8
LC_CTYPE=pl_PL
LC_NUMERIC=pl_PL.UTF-8
LC_TIME=pl_PL.UTF-8
LC_COLLATE=POSIX
LC_MONETARY=pl_PL.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=pl_PL.UTF-8
LC_NAME=pl_PL.UTF-8
LC_ADDRESS=pl_PL.UTF-8
LC_TELEPHONE=pl_PL.UTF-8
LC_MEASUREMENT=pl_PL.UTF-8
LC_IDENTIFICATION=pl_PL.UTF-8
LC_ALL=
LC_NUMERIC
is the culprit. Now you (we) need to investigate why the difference.SendEnv LANG LC_*
in/etc/ssh/ssh_config
. Nowsort -g
works fine.(echo 0.1; echo 9.1e-02) | LC_NUMERIC=pl_PL.UTF-8 sort -g
or(echo 0.1; echo 9.1e-02) | LC_ALL=pl_PL.UTF-8 sort -g
I get the same correct sort order as with other countries. So there must be some cause other than just the LC_* environment variables.