Sort with case-sensitivity in macOS in the Terminal

2

I am trying to use the answer in GNU Sort by case-sensitive to sort a file in my Mac OS.

My file.txt looks like this:

"Best"
"A"
"BEST"

In the second answer to the mentioned question, it says that one can do:

echo -e "d\nD\nc\nb\nB\na" | sort --ignore-case file.txt

and the output should be:

"A"
"Best"
"Best"

However, when I do it in my computer, I get:

"A"
"BEST"
"Best"

It does not matter if I use the --ignore-case or not, the output is the same.

Maybe LC_COLLATE=C can not be set in Mac OS?

Does someone know how to use sort and have lowercase < uppercase in Mac OS?

regina_fallangi

Posted 2018-09-05T14:06:14.973

Reputation: 121

https://apple.stackexchange.com/questions/34054/case-insensitive-ls-sorting-in-mac-osx/81791#81791 indicates sort in MacOS does not work like it does in GNU sort. https://apple.stackexchange.com may be a more useful place to ask this question. – K7AAY – 2018-09-05T20:17:22.857

No answers