Sort Oddity


 
Thread Tools Search this Thread
Operating Systems Solaris Sort Oddity
# 1  
Old 10-26-2010
Question Sort Oddity

All,

I'm baffled by some sort behavior on SunOS 5.10 and looking for guidance.

Running the command:
Code:
sort -t'|' -k5,5 -k7,7 -k1,1 -k2,2 -k3,3 -k6,6 -k8,8 test

Against the file "test":
Code:
thirdA||||first||second|Data
thirdB||||first||second|
thirdC||||first||second|Data
thirdD||||first||second|Data

Yields:
Code:
thirdA||||first||second|Data
thirdC||||first||second|Data
thirdD||||first||second|Data
thirdB||||first||second|

Since the first (5) and second (7) sort keys are equal, I'm expecting the differentiating factor to be the third (1) and for the file to look as it did prior to the sort; however, because thirdB's last field (8) is blank, it appears at the bottom. If I put any content in this field it sorts as expected.

I get the same results whether my locale is "C" or "en_US.ISO8859-1." Can someone explain this behavior or how to achieve the sort I'm after?

Thanks much!
# 2  
Old 10-26-2010
Solaris has a bad sort at one point! This is old HPUX:

Code:
 
$ sort -t'|' -k5,5 -k7,7 -k1,1 -k2,2 -k3,3 -k6,6 -k8,8 <<!
thirdA||||first||second|Data
thirdB||||first||second|
thirdC||||first||second|Data
thirdD||||first||second|Data
!
thirdA||||first||second|Data
thirdB||||first||second|
thirdC||||first||second|Data
thirdD||||first||second|Data

$

# 3  
Old 10-26-2010
Quote:
Originally Posted by effigy
All,

I'm baffled by some sort behavior on SunOS 5.10 and looking for guidance.

Running the command:
Code:
sort -t'|' -k5,5 -k7,7 -k1,1 -k2,2 -k3,3 -k6,6 -k8,8 test

Against the file "test":
Code:
thirdA||||first||second|Data
thirdB||||first||second|
thirdC||||first||second|Data
thirdD||||first||second|Data

Yields:
Code:
thirdA||||first||second|Data
thirdC||||first||second|Data
thirdD||||first||second|Data
thirdB||||first||second|

Since the first (5) and second (7) sort keys are equal, I'm expecting the differentiating factor to be the third (1) and for the file to look as it did prior to the sort; however, because thirdB's last field (8) is blank, it appears at the bottom. If I put any content in this field it sorts as expected.

I get the same results whether my locale is "C" or "en_US.ISO8859-1." Can someone explain this behavior or how to achieve the sort I'm after?

Thanks much!
For me it works ...
Code:
# cat tst
thirdA||||first||second|Data
thirdB||||first||second|
thirdC||||first||second|Data
thirdD||||first||second|Data
# sort -t'|' -k5,5 -k7,7 -k1,1 -k2,2 -k3,3 -k6,6 -k8,8 tst
thirdA||||first||second|Data
thirdC||||first||second|Data
thirdD||||first||second|Data
thirdB||||first||second|
# uname -a
SunOS <anonymized> 5.10 Generic_127111-10 sun4us sparc FJSV,GPUZC-M
#

Are you running SPARC ?
Is your system up to date ?
By the way ... it is a good habit not to use "test" as a file name since it is a command name.
This User Gave Thanks to ctsgnb For This Post:
# 4  
Old 10-26-2010
This User Gave Thanks to DGPickett For This Post:
# 5  
Old 10-26-2010
We're SPARC and apparently lacking updates. I wonder if there's a workaround? I'll research further and see what we can do about updating. Thanks!
Code:
SunOS <anonymized> 5.10 Generic_137137-09 sun4v sparc SUNW,T5240

# 6  
Old 10-26-2010
gnu sort = coreutils, or download fix.

I found this funny note:

http://dlc.sun.com/pdf/819-7324/819-7324.pdf

Sort Capability in the European UTF-8 Locales Does
Not Function Correctly (4307314)
The sort capability in the European UTF-8 locales does not work properly.
Workaround: Before you attempt to sort in a FIGGS UTF-8 locale, set the LC_COLLATE
variable to the ISO1 equivalent.
# echo $LC_COLLATE
> es_ES.UTF-8
# LC_COLLATE=es_ES.IS08859-1
# export LC_COLLATE
Then start sorting.

Last edited by DGPickett; 10-26-2010 at 05:28 PM..
This User Gave Thanks to DGPickett For This Post:
# 7  
Old 10-26-2010
Thanks DG. One last inquiry here: How do I find a detailed description of the bug (so I can pass it onto our admins)? I tried searching bugs.sun.com with the two numbers in your link ("118824-01" and "6178339"), but I'm not getting any results. I've searched plenty of non-Sun bug sites with success; what am I missing?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

System call oddity

Hi all, I'm trying to use bash to create a basic parser for some text, because basic grep/sed/awk have all my needs covered. So, I'm creating the chain of grep/sed I need and trying the execute that on the data I gather. The problem is, it's not working as it does when hardcoded. e.g. ... (3 Replies)
Discussion started by: beomagi
3 Replies

2. UNIX for Dummies Questions & Answers

[Solved] awk oddity

I have to apologize for my ignorance so this question is probably stupid. How does awk process a file? Does it read from top of input file to end of file going line by line? Yoda helped me create an awk script that helps me parse the named.conf file and output it into a .csv file but when... (8 Replies)
Discussion started by: djzah
8 Replies

3. Programming

Java double subtraction oddity (not the usual rounding discrepancy)

I've been going through a java tutorial, and ran across some strangeness in this small example... class SqrRoot { public static void main(String args) { double num,sroot,rerr,resquare; for(num = 1.0; num < 100.0; num++) { sroot = Math.sqrt(num); ... (1 Reply)
Discussion started by: Trones
1 Replies

4. BSD

Cron Oddity

Our webserver is running FreeBSD, for the last few days we have been having an issue with our cronjobs/mysql server. Specifically we have jobs that execute php scripts to do various things to the website. When running these php scripts manually, via external browser, or lynx on the server, they... (8 Replies)
Discussion started by: mrfr0g
8 Replies

5. UNIX for Dummies Questions & Answers

TR squeeze oddity

I discovered that where 'tr -s' works as expected on grepped input, it appears to completely fail on dig results. I am not sure if this is because of some sort of non posix compliancy, or what. Here is what I did: The command below works as expected, squeezing all repeated spaces to a single... (3 Replies)
Discussion started by: bdmeyersc
3 Replies

6. AIX

AIX SAN configuration problems/oddity

Hi, I have a strange problem. we're trying to connect an IBM pseries, to a Brocade switch, for SAN acess, using a badged emulex card, (IBM FC6239) WE can configure the device to see the fabric. The only problem we have is that the Brocade sees the HBA as storage, and not as a HBA. We've zoned... (1 Reply)
Discussion started by: praxis22
1 Replies

7. UNIX for Dummies Questions & Answers

VSFTP oddity

I am using smartFTP client on my windows machine to connect to a linux box of mine (different location) to download some large files 100+meg. The linux box is running vsftp. After several minutes of downloading, the connection suddenly dies, and I cannot reconnect to the box via FTP using ANY... (7 Replies)
Discussion started by: Spetnik
7 Replies

8. UNIX for Dummies Questions & Answers

Su Password Oddity

Hello Forum, I am having an odd occurence. When i do a su in a terminal or console session, I am able get authenticated as superuser without using the full or correct root password. Anyone have any idea? -AJ (4 Replies)
Discussion started by: jacobsa
4 Replies

9. UNIX for Dummies Questions & Answers

Textual oddity

This is my first post!! I really hope this question hasn't been asked a thousand times before(I'll bet it has). Anyway, here it is. I am new to the UNIX world by the way so forgive my ignorance. OK, whenever I write code on my windows machine and then try to port it over to UNIX I always get... (3 Replies)
Discussion started by: Jubba
3 Replies
Login or Register to Ask a Question