help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sort


From: Bob Proulx
Subject: Re: sort
Date: Mon, 4 Aug 2014 13:29:01 -0600
User-agent: Mutt/1.5.23 (2014-03-12)

sudhakara.maddukuri@consult.nordea.com wrote:
> Sort -A [Filename] is not working.

GNU sort does not have a -A option.

  $ sort -A
  sort: invalid option -- 'A'
  Try `sort --help' for more information.

Are you sure you are using GNU sort?  I suspect you are using a
different sort.  Probably a vendor sort.  Ask it for the version.

  $ sort --version
  sort (GNU coreutils) 8.13

> How to handle Sorts on a byte-by-byte basis using ASCII collation
> order instead of collation in the current locale using sort command
> Please help me

Set the LC_ALL=C variable for sort.  Or at least LC_COLLATE=C.  If you
are using a /bin/sh or derivative then you can do this on the command
line for sort by placing the variable setting before the command.

  LC_ALL=C sort

If you are using one of the csh derived shells then you can use the
"env" program as a helper.  Some people document env only since it
will always work correctly regardless of shell or function or aliases.

  env LC_ALL=C sort

In my ~/.profile I set the following.  It sets the LANG to UTF-8 so
that I get unicode characters but overrides the collation sequence to
be C so that I always get byte comparisons for a traditional Unix sort
order.  This works for en_US.UTF-8 and for most other western
languages.  But I have no idea how it would interact with chinese big5
for example.  It may be a good compromise for you as well.

  export LANG=en_US.UTF-8
  export LC_COLLATE=C

There is an FAQ with more information here:

  
https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#Sort-does-not-sort-in-normal-order_0021

> Note: Its working in IBM AIX

It is likely that your AIX locale is already set to C (or POSIX, an
alias for C).

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]