36
4
The sort
utility in Ubuntu 10.04 (Lucid) always sort by case-insensitive, just like if you specify --ignore-case
to it.
The two sort just give the same result:
echo -e "c\nb\nB\na" | sort
echo -e "c\nb\nB\na" | sort --ignore-case
But sometimes I want to sort by case-sensitive, so the upper-case letters come first, then lower-case letter. Is it possible?
Regarding "foreign characters", the
C.UTF-8
locale (LC_COLLATE=C.UTF-8
) will sort case-sensitively, while treating non-ascii UTF-8 characters "normally". Unfortunately, it's not available upstream in glibc and only patched in by Debian, Ubuntu and derivatives. – aplaice – 2019-08-09T09:54:43.9176This works, but by definition only if no foreign chars. are in play; they will sort after the 7-bit ASCII letters; try
echo $'B\nÄ\nb\na' | LC_COLLATE=C sort
. Shouldn't the fact that GNUsort
with a non-C
locale always performs case-INsensitive sorting be considered a bug? – mklement0 – 2014-05-28T17:38:17.523