bug-coreutils
[Top][All Lists]
Advanced

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

RE: Reg. 'sort' problem in Mac OS X


From: Mallika Veeramalai
Subject: RE: Reg. 'sort' problem in Mac OS X
Date: Thu, 30 Aug 2007 21:25:52 -0700

Hi Eric Blake,

Thank for your email.  This problem is solved when I used the command 'sort -g 
-k1,1 t.txt'.

where -k1,1 indicates first field and all characters, you could also use 'sort 
-g - k1.1,1.8' which represents first field and 1 to 8 characters.

I hope this problem is solved for time being.

Thank you very much,
mallika


From: Eric Blake [mailto:address@hidden
Sent: Thu 8/30/2007 7:32 PM
To: Mallika Veeramalai
Cc: address@hidden
Subject: Re: Reg. 'sort' problem in Mac OS X
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Mallika Veeramalai on 8/30/2007 6:17 PM:
> The command 'sort -g -k 1 t.txt' gives the following result.
> 
> 1.46e-13 H
> 1.53e-11 H
> 1.54e-03 H

Although it didn't seem like this was your question, I think you should
beware the difference between '-k1,1' and '-k1'.  As typed in your
example, the sort key is the entire line, rather than just the first field.

> 
> I think this 'sort' problem exist in every where, even when we use the
> 'ls -trl' to list the file in a dir - mainly because many sort options not
> included in the Mac OS X 10.4.10 version.

I'm not quite sure what question you are asking, so here's the question I
will answer: "Why doesn't the sort provided natively with MacOS X 10.4.10
provide the -g option?"

In which case, the answer is, this is the wrong list to ask the question
on.  'sort -g' is a GNU extension, provided by GNU coreutils, but not
required by standards bodies.  Therefore, if MacOS ships with their own
sort, rather than the GNU coreutils version, then they don't have to
support -g; and if you want it to support -g, you should ask on a MacOS
support forum.

Fortunately, there is no law that says you can't also install GNU
coreutils on a MacOS X 10.4.10 system, and put its location first in your
PATH, in order to choose the GNU sort instead of the Mac native sort.  But
keep in mind that using GNU extensions in scripts means your scripts are
no longer portable to non-GNU systems, as you discovered.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG133M84KuGfSFAYARAiAgAJ9W3qQMYQ+XVO6Em8/C4SURSNfsrwCdHAtn
pj0iNxJ7Bcp0OV7NOiHn1yE=
=XYLn
-----END PGP SIGNATURE-----



reply via email to

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