sort [-c|-m] -bfirdMn† infile [ … ]
sort
has three modes of operation: Sort(default), Check, and Merge
--check |
Sort always works ; merging is faster.
bfirdMn
may be specified globally and/or appended to a key .
If no key fields are specified, global options apply to comparison of entire lines.
Global options are inherited by keys that do not specify options.
The --ignore-leading-blanks (-b)
, --dictionary-order (-d)
, --ignore-case (-f)
and
ignore unprintable (-i
)
options are dependent on LC_CTYPE
locale.
LC_COLLATE
using fields ( not absolute columns ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Compares each pair of fields using the collating sequence specified by the LC_COLLATE
locale, Unless otherwise specified.
If global --Month-sort, --blankIgnore, --directory, --fold, --ignoreUnprintable, --numerical
or --reverse
are given without key fields, the entire lines is compared according to the global options.
When all keys compare equal (or if no ordering options were specified ), sort
compares the entire lines honoring --reverse
.
-s
(stable) lines in which all fields compare equal are left in their original relative order. If no fields or global options are specified, -s
has no effect.
If the final byte of an input file is not a newline one is added.
A line's trailing newline is part of the line for comparison purposes; for example, with no options in an ASCII locale,
a line starting with tab
sorts before an empty line because tab precedes newline.
Upon error, sort
exits with a status of 2
.
With --ignore-leading-blanks
the column part of a field is counted from the first nonblank character
of the field (for +POS ) |
AAAAA BBBBB 12345 |
following the previous field (for -POS )
| AAAAA BBBBB 12345 |
A key may have Mbdfinr
appended to it, which overides global options for this key.
-b
(ignore leading blanks) may be
attached to either or both of the +POS
and -POS
parts of a field
specification, If inherited from global options it will
be attached to both. Keys may span multiple fields.
Some implementations treat -b
,
-f
, and -n
.
GNU sort follows the POSIX behavior, -n
does not imply -b
.
-M
has been changed in the same way.
This may affect the meaning of character positions in field specifications in obscure cases.
If in doubt add an explicit -b
.