RE: sort

<[email protected]> Tue, 5 Aug 2014 09:10:33 +0200
Newsgroups gmane.comp.gnu.utils
Message-ID <F5A9EDA13F86E2419A3E6A76E79662E038A8756DE4@CCD1XM1102.ccd1.root4.net>
Thank you for your help Bob:):)



/BR

M. Sudhakara Rao

-----Original Message-----
From: Bob Proulx [mailto:[email protected]]
Sent: Monday, August 04, 2014 9:29 PM
To: Maddukuri, Sudhakara
Cc: [email protected]
Subject: Re: sort



[email protected]<mailto:[email protected]=
ordea.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 s=
ort.  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=3DC variable for sort.  Or at least LC_COLLATE=3DC.  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=3DC sort



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



  env LC_ALL=3DC 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 wor=
ks for en_US.UTF-8 and for most other western languages.  But I have no ide=
a how it would interact with chinese big5 for example.  It may be a good co=
mpromise for you as well.



  export LANG=3Den_US.UTF-8

  export LC_COLLATE=3DC



There is an FAQ with more information here:



  https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#Sort-does-n=
ot-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 f=
or C).



Bob