Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why does sorting in Emacs vs bash produce differing outputs? What can I do to get the same result in both?

This is the output of diff two files, one sorted in Emacs with sort-lines, and the other in bash with sort command:

> /perl5/Filter/
> /perl5/Filter/Crypto/
> /perl5/Filter/Crypto/
< /perl5/Filter/Crypto/
< /perl5/Filter/Crypto/
< /perl5/Filter/
share|improve this question
Could you redo the diff with diff -u? That would make it easier to read. – legoscia Dec 21 '12 at 17:50
I found LANG=C solves the problem, but I don't know why – Zhen Dec 22 '12 at 6:59
up vote 1 down vote accepted

Setting the language with the LANG environment variable determines (amongst others) the collation settings, that is, the sorting order of characters. Probably in your original LANG setting, the order of / and . is reversed w.r.t. the default LANG=C.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.