[ILUG] [LONG] sort strangeness ?

Padraig Brady padraig.brady at corvil.com
Tue Dec 17 11:49:03 GMT 2002


Declan Grady wrote:
> Hi,
> I have a bash script to ftp, sort and join two ascii files from another box, 
> then diff the resulting file with the equivalent file from yesterday.
> However, the sort command seems to work differently when in the script, 
> compared to when I run the same series of commands at the bash prompt.
> 
> sort (GNU textutils) 2.0e
> 
> I even tried sorting the files twice, as when I sorted the already sorted file 
> at the command prompt, it changed the order.
> 
> Below are snippets from script and 'head' of files before and after sorting at 
> command prompt.
> 
> Any suggestions ?

Sorting is actually very complex as locales have to be taken into a/c.
The script and command prompt aren't different users by any chance?
More accurately do they have different LANG LC_ALL or LC_COLLATE
environment variables. If you just want ascii order then do:

   export LC_ALL=C

in your script. To quickly test at the command prompt:

   LC_ALL=C sort ...

Padraig.




More information about the ILUG mailing list