15

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).

3
  • Which locale do you use? Commented May 12, 2011 at 18:38
  • I had "LANG=en_US.UTF-8" Commented May 12, 2011 at 18:50
  • Also found this link: superuser.com/questions/226449/… echo -e 'TEST.b\nTESTa\nTESTc' | sort -V also works without setting to locale. Commented May 12, 2011 at 18:50

2 Answers 2

23

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
Sign up to request clarification or add additional context in comments.

1 Comment

I tried LC_ALL=C but it seems to fail in some cases? LC_COLLATE=C worked best!
0
$ echo -e 'TEST.b\nTESTa\nTESTc' | env -i sort

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.