Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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:

25a26,28
> /perl5/Filter/Crypto.pm
> /perl5/Filter/Crypto/CryptFile.pm
> /perl5/Filter/Crypto/Decrypt.pm
29,32d32
< /perl5/Filter/Crypto/CryptFile.pm
< /perl5/Filter/Crypto/Decrypt.pm
< /perl5/Filter/Crypto.pm
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

1 Answer 1

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

 
discard

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.