I have a file containing lines, some of which start with a !
character, some with a ?
character, and some with a space (
) character. The second character is always a letter of the alphabet.
When I try to use the bash sort
command from coreutils, this seems to ignore the the first character, and sort according to the second only.
This surprised me very much, as I assumed the sort would treat the punctuation numbers by their ascii value, and lump all the !
lines together, followed by all the ?
lines together, etc.
In particular, the documentation says there's a -d
option, which explicitly instructs the sort
command to ignore such punctuation marks. But what I want is the opposite behaviour, and there's no option to 'reverse' this behaviour. It's as if the -d
option has been "baked in" somehow.
I have checked, and as far as I know, I don't have an alias defined somewhere that might activate the -d
flag by accident.
Is this a bug in sort
? (coreutils v8.32). Is there a way to force it NOT to sort by dictionary order but by strict ascii value?
OS: Linux Mint 21.1 (based on ubuntu jammy, afaik) in case this is relevant
EDIT: Providing locale and MVP as requested
$ locale
LANG=en_GB.UTF-8
LANGUAGE=en_GB:en
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC=en_GB.UTF-8
LC_TIME=en_GB.UTF-8
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY=en_GB.UTF-8
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER=en_GB.UTF-8
LC_NAME=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
LC_TELEPHONE=en_GB.UTF-8
LC_MEASUREMENT=en_GB.UTF-8
LC_IDENTIFICATION=en_GB.UTF-8
LC_ALL=
$ echo '
> !a
> ?b
> c
> !f
> e
> ?d' | sort
!a
?b
c
?d
e
!f