HP-UX Reference (11i v1 05/09) - 1 User Commands N-Z (vol 2)
s
sort(1) sort(1)
The following options override the default ordering rules:
-d Quasi-dictionary order: only alphanumeric characters and blanks (spaces and tabs), as
defined by LC_CTYPE are significant in comparisons (see environ(5)).
(XPG4 only.) The behavior is undefined for a sort key to which -i or -n also applies.
-f Fold letters. Prior to being compared, all lowercase letters are effectively converted into
their uppercase equivalents, as defined by
LC_CTYPE.
-i In non-numeric comparisons, ignore all characters which are non-printable, as defined by
LC_CTYPE. For the ASCII character set, octal character codes 001 through 037 and 0177
are ignored.
-n The sort key is restricted to an initial numeric string consisting of optional blanks, an
optional minus sign, zero or more digits with optional radix character, and optional
thousands separators. The radix and thousands separator characters are defined by
LC_NUMERIC . The field is sorted by arithmetic value. An empty (missing) numeric
field is treated as arithmetic zero. Leading zeros and plus or minus signs on zeros do not
affect the ordering. The -n
option implies the -b option (see below).
-r Reverse the sense of comparisons.
-M Compare as months. The first several non-blank characters of the field are folded to
uppercase and compared with the langinfo(5) items ABMON_1 < ABMON_2 < ... <
ABMON_12. An invalid field is treated as being less than ABMON_1 string. For exam-
ple, American month names are compared such that JAN < FEB < ... < DEC. An invalid
field is treated as being less than all months. The
-M option implies the -b option (see
below).
Field Separator Options
The treatment of field separators can be altered using the options:
-t char Use char as the field separator character; char is not considered to be part of a field
(although it can be included in a sort key). Each occurrence of char is significant (for
example, <char><char> delimits an empty field). If -t is not specified, <blank> charac-
ters will be used as default field separators; each maximal sequence of <blank> charac-
ters that follows a non-<blank> character is a field separator.
-b Ignore leading blanks when determining the starting and ending positions of a restricted
sort key. If the -b option is specified before the first -k option (
+pos1 argument), it is
applied to all
-k options (+pos1 arguments). Otherwise, the -b option can be attached
independently to each -k field_start or field_end option (+pos1 or (-
pos2 argument; see
below). Note that the
-b option is only effective when restricted sort key specifications
are given.
Restricted Sort Key
-k keydef The keydef argument defines a restricted sort key. The format of this definition is
field_start [ type ][,field_end[type ]]
which defines a key field beginning at field_start and ending at field_end. The characters
at positions field_start and field_end are included in the key field, providing that field_end
does not precede field_start. A missing field_end means the end of the line. Fields and
characters within fields are numbered starting with 1. Note that this is different than
the obsolete form of restricted sort keys, where numbering starts at 0. See WARNINGS
below.
Specifying field_start and field_end involves the notion of a field, a minimal sequence of
characters followed by a field separator or a new-line. By default, the first blank of a
sequence of blanks acts as the field separator. All blanks in a sequence of blanks are con-
sidered to be part of the next field; for example, all blanks at the beginning of a line are
considered to be part of the first field.
The arguments field_start and field_end each have the form m.n which are optionally
followed by one or more of the type options b, d, f, i, n, r,orM. These modifiers have
the functionality for this key only, that their command-line counterparts have for the
entire record.
Section 1−−932 Hewlett-Packard Company − 2 − HP-UX 11i Version 1: September 2005