Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Behaviour of GNU sort command (with non-letter ASCII characters, such as dot or semicolon)

I want the sort command to treat all characters equal.

For example, when I do

$ echo -e 'TEST.b\nTESTa\nTESTc' | sort
TESTa
TEST.b
TESTc

the dot is ignored.

I would like to get TEST.b at the last or first position. However, I cannot find the proper parameter in the manual page.

(my version of sort is from the GNU core utilities).

like image 295
thaller Avatar asked May 12 '11 18:05

thaller


1 Answers

Force collation to C in order to compare the raw character values.

$ echo -e 'TEST.b\nTESTa\nTESTc' | LC_COLLATE=C sort
TEST.b
TESTa
TESTc
like image 87
Ignacio Vazquez-Abrams Avatar answered Oct 05 '22 00:10

Ignacio Vazquez-Abrams