Given a file txt
:
ab a c a a
When calling sort txt
, I obtain:
a a ab a c
In other words, it is not proper sorting, it kind of deletes/ignores the whitespaces! I expected this to be the behavior of sort -i
but it happens with or without the -i
flag.
I would like to obtain "correct" sorting:
a a a c ab
How should I do that?
Solved by:
export LC_ALL=C
From the sort()
documentation:
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.
(works for ASCII at least, no idea for UTF8)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With