HP-UX Reference (11i v1 05/09) - 1 User Commands N-Z (vol 2)
s
sort(1) sort(1)
A field_start position specified by m
.n is interpreted to mean the nth character in the
mth field. A missing n means
.1, indicating the first character of the mth field. If the
-b option is in effect, n is counted from the first non-blank character in the mth field.
A field_end position specified by m
.n is interpreted to mean the nth character in the mth
field. If n is missing, the mth field ends at the last character of the field. If the
-b
option is in effect, n is counted from the first non-<blank> character in the mth field.
Multiple
-k options are permitted and are significant in command line order. A max-
imum of 9 -k options can be given. If no
-k option is specified, a default sort key of the
entire line is used. When there are multiple sort keys, later keys are compared only
after all earlier keys compare equal. Lines that otherwise compare equal are ordered
with all bytes significant. If all the specified keys compare equal, the entire record is
used as the final key.
The
-k option is intended to replace the obsolete [
+pos1 [+pos2 ] ] notation, using
field_start and field_end respectively. The fully specified [
+
pos1 [+pos2 ]] form:
+w.x-y.z
is equivalent to:
-k w+1.x+1,y.0 (if z == 0)
-k w+1.x+1,y+1.z (if z >0)
Obsolete Restricted Sort Key
The notation
+pos1 -pos2 restricts a sort key to one beginning at pos1 and ending at pos2. The characters
at positions pos1 and pos2 are included in the sort key (provided that pos2 does not precede pos1). A miss-
ing
-pos2 means the end of the line.
Specifying pos1 and pos2 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 (space or tab) of a sequence of blanks acts as the field
separator. All blanks in a sequence of blanks are considered 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.
pos1 and pos2 each have the form m.n optionally followed by one or more of the flags
bdfinrM. A start-
ing position specified by
+m.n is interpreted to mean character n+1 in field m+1. A missing
.n means .0,
indicating the first character of field m+1. If the
b flag is in effect, n is counted from the first non-blank in
field m+1;
+m.0b refers to the first non-blank character in field m+1.
A last position specified by
-m.n is interpreted to mean the nth character (including separators) after the
last character of the mthfield. A missing
.n means .0, indicating the last character of the mth field. If
the
b flag is in effect, n is counted from the last leading blank in field m+1;
-m.1b refers to the first non-
blank in field m+1.
EXTERNAL INFLUENCES
Environment Variables
LC_COLLATE determines the default ordering rules applied to the sort.
LC_CTYPE determines the locale for interpretation of sequences of bytes of text data as characters (e.g.,
single- verses multibyte characters in arguments and input files) and the behavior of character classification
for the -b, -d, -f, -i, and -n options.
LC_NUMERIC determines the definition of the radix and thousands separator characters for the -n
option.
LC_TIME determines the month names for the -M option.
LC_MESSAGES determines the language in which messages are displayed.
LC_ALL determines the locale to use to override the values of all the other internationalization variables.
NLSPATH determines the location of message catalogs for the processing of LC_MESSAGES .
LANG provides a default value for the internationalization variables that are unset or null. If
LANG is
unset or null, the default value of "C" (see lang(5)) is used.
If any of the internationalization variables contains an invalid setting,
sort behaves as if all internation-
alization variables are set to "C". See environ(5).
HP-UX 11i Version 1: September 2005 − 3 − Hewlett-Packard Company Section 1−−933