2

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
2
  • Could you redo the diff with diff -u? That would make it easier to read.
    – legoscia
    Dec 21, 2012 at 17:50
  • I found LANG=C solves the problem, but I don't know why
    – Zhen
    Dec 22, 2012 at 6:59

1 Answer 1

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .