behaviour of sort command

PleegWat pleegwat at telfort.nl
Fri Jan 20 23:56:42 UTC 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/20/2012 10:57 PM, Dan Christensen wrote:
> Is this a bug in sort?  It's not explained in the man page or the
> info page, and I think most people would expect that adding text to
> the end of unequal lines shouldn't change their sort order.

How sort sorts depends on your localization settings (specifically the
value of LC_COLLATE). Example:

$ LC_COLLATE=en_US.UTF-8
$ echo -e " 1\n_1\n 2\n_2" | sort
 1
_1
 2
_2
$ LC_COLLATE=C
$ echo -e " 1\n_1\n 2\n_2" | sort
 1
 2
_1
_2

Typically LC_COLLATE=C corresponds to sorting the actual byte order.

See `man locale`

PleegWat
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPGf81AAoJEAM6sLJjDJaMwDcIAJbqwA/QWzn6KIAwqTa7nfta
9hUxGUr368Lluu27Dy8luU0iFP+Gx88P9ArPAOM7dVsbb4yMNJ58bSXd05d5yNfZ
sIvUW8WEuazoH1xKDuXs7PSHFB6tQFxXGht4ErjwRtAamPDgF4a7HcSeusHkBdbY
wsBmN/OifVz9AAVkriNz4q/3aI4EOICd+a7C926IREl3R+AWUeHZOiq5mGQMhVtK
3U0D9a5sHGGiF8yj5i/ag4DDROutHwICbOF4TuusrXTmkYUT+Nyltj5GW4lsqJrH
q1jzx3yEUlSh/59E18LMooUWTNGbHpKGCUBV6DIwsRniGVwrynpaganupJecxCE=
=uB6l
-----END PGP SIGNATURE-----




More information about the ubuntu-users mailing list