[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Behavior of sort with no options
From: |
ksykora |
Subject: |
Behavior of sort with no options |
Date: |
Thu, 2 Nov 2000 15:04:35 -0500 |
I was surprised to get the following output from sort with no options.
2000 10 10 0 2 500
2000 10 1 0 2 500
2000 10 11 0 2 500
2000 10 12 0 2 500
A sharp eyed friend pointed out that the observed order was the result
of deleting all blanks.
2000101002500
200010102500
2000101102500
2000101202500
My reading of the documentation did not lead me to expect this behavior.
" If any of the global options `Mbdfinr' are given but no key fields
are specified, `sort' compares the entire lines according to the global
options.
Finally, as a last resort when all keys compare equal (or if no
ordering options were specified at all), `sort' compares the entire
lines."
Have I misinterpreted the documentation? Is the behavior observed the
intended behavior when no options are specified?
The reason this came to my attention was the failure of a shell script
which I ported to Gnu/Linux from HP-UX. The HP-UX sort would have given
the following.
2000 10 1 0 2 500
2000 10 10 0 2 500
2000 10 11 0 2 500
2000 10 12 0 2 500
I will admit to preferring the latter default behavior in the absence of
options.
Is it reasonable to remove all blanks when no keys have been specified?
- Behavior of sort with no options,
ksykora <=