MLUG: Re: [MLUG] annoyance with GNU sort within system call
Re: [MLUG] annoyance with GNU sort within system call
Email address obfuscation in effect -- please click here to turn it off.

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

The exec series (man 3 exec) knows an extern char **environ to manipulate the 
environment (see man 5 environ).

Mark


On Friday 06 February 2004 12:43, Mike Miller wrote:
> I have been using 'sort' to sort files that contain numbers aligned in
> columns.  Here is a very simple example:
>
>  1
>  2
> 10
>
> On Solaris, sort will order lines as above.  On the other hand, GNU sort
> orders the lines like this:
>
>  1
> 10
>  2
>
> Now I read this in the GNU sort man page:
>
>   *** WARNING *** The locale specified by the  environment  affects  sort
>   order.  Set LC_ALL=C to get the traditional sort order that uses native
>   byte values.
>
> So I did this in my tcsh shell...
>
> setenv LC_ALL C
>
> ...and suddenly sort is working the way I want it to!
>
> Now here's the annoyance part of it (as if that wasn't annoying
> enough!)...  I have written a C program that calls sort from the system to
> process some data.  But it looks like the functioning of 'sort' will
> depend on environment variables.  Is it possible to write the C program so
> that LC_ALL is set to C when sort is called?  Do you have any other ideas
> on how to handle this problem?  (I could use "sort -n" with some
> additional arguments to control sort keys, but those sorting-key arguments
> vary with the unix OS.)
>
> Thanks in advance for any tips!
>
> Mike
> _______________________________________________
> members mailing list
> EMAIL:PROTECTED
> http://mlug.missouri.edu/mailman/listinfo/members

-- 
- - - - - - - - - - - - - - - - - - - - - -
Mark A. Haidekker, Ph.D.
Assistant Professor
University of Missouri-Columbia
Department of Biological Engineering
252 Ag Eng Bldg, 1406 E. Rollins St
Columbia, MO 65211
Phone: (573) 884-4943
Fax: (573) 884-5650
Email: EMAIL:PROTECTED
Web: http://haidekker-lab.missouri.edu

_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members