sort5.1
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 1 代码 · 共 334 行
1
334 行
.TH sort5 1.SH Namesort5 \- internationalized System 5 sort and/or merge files.SH Syntax.NXR "sort5 command".B sort5.RB [ \-cmu ].RB [ \-o output].RB [ \-y kmem].RB [ \-z recsz].RB [ \-X].RB [ \-dfiMnr ].RB [ \-bt x].RB [ + pos1.RB [ \- pos2]][\fIfiles\fR].SH DescriptionThe.PN sort5command sorts lines of the named files togetherand writes the result onthe standard output. The standard input is read if a hyphen(\fB-\fR) is used as a file nameor if no input files are named..PPComparisons are based on one or more sort keys extractedfrom each line of input.By default, there is one sort key, the entire input line,and ordering is determined by the collating sequence specified by the LC_COLLATElocale. The LC_COLLATE locale is controlled by the settings ofeither the LANG or LC_COLLATE environment variables. See.PN setlocale(3int)for more information..SH OptionsThe following options alter the default behavior:.TP 5.B \-cChecks that the input file is sorted according to the ordering rules;gives no output unless the file is out of order..TP.B \-mMerges only; the input files are already sorted..TP.B \-uSuppresses all but one in eachset of lines having equal keys..TP.BI \-o outputSpecifies the name of an output fileto use instead of the standard output.The file may be the same as one of the inputs.Blanks between .B \-oand.IR outputare optional..TP.BI \-y kmemSpecifies the number of kilobytes of memory to use when sorting a file.If this option is omitted,.I sort5begins using a system default memory size,and continues to use more space as needed.If.IR kmem is specified,.I sort5starts using that number of kilobytes of memory.If the administrative minimum or maximum is violated,the value of the corresponding minimum or maximum is used.Thus,.BR \-y 0is guaranteed to start with minimum memory.By convention,.B \-y(with no argument) starts with maximum memory..TP.BI \-z recszRecords the size of the longest line read in the sort phase so buffers can be allocatedduring the merge phase.If the sort phase is omitted using either the.B \-cor.B \-moptions, a system default size is used.Lines longer than the buffer size cause.PN sort5to terminate abnormally.Supplying the actual number of bytes (or some larger value)in the longest lineto be mergedprevents abnormal termination..TP.B \-XSorts using tags. Upon input each key is converted to a tagvalue which is sorted efficiently. This optionmakes international sorting faster but it consumes more memorysince both key and tag must be stored..PPThe following options override the default ordering rules:.TP 5.B \-dSpecifies Dictionary order. Only letters, digits and blanks(spaces and tabs) are significant in comparisons..TP.B \-fFolds lower caseletters into upper case..TP.B \-iIgnores characters outside the ASCII range 040-0176in non-numeric comparisons..TP.B \-nSorts an initial numeric string,consisting of optional blanks, optional minus sign,and zero or more digits with optional decimal point,by arithmetic value.The.B \-noption implies the.B \-boption, which tells the .PN sort5command to ignore leading blanks when determining thestarting and ending positions of a restricted sort key..TP.B \-rReverses the sense of comparisons..PPWhen ordering options appear before restrictedsort key specifications, the requested ordering rules areapplied globally to all sort keys.When attached to a specific sort key (described below),the specified ordering options override all global ordering optionsfor that key..PPThe notation.BI + pos1.BI \- pos2restricts a sort key to one beginning at.I pos1and ending at.IR pos2 .The characters at positions.I pos1and.I pos2are included in the sort key (provided that.I pos2does not precede.IR pos1 ).A missing.BI \- pos2means the end of the line..PPSpecifying.I pos1and.I pos2involves the notion of a field, that isa minimal sequence of characters followedby a field separator or a new-line.By default, the first blank of a sequence ofblanks acts as the field separator. The blank can beeither a space or a tab.All blanks in a sequence of blanks are interpreted as apart of the next field; for example,all blanks at the beginning of a line are considered to be part ofthe first field.The treatment of field separators is altered using the followingoptions:.TP 5.BI \-t xUses.I xas the field separator character.Although it may be included in a sort key,.I xis not considered part of a field.Each occurrence of.I xis significant(for example,.I xxdelimits an empty field)..TP.B \-bIgnores leading blanks when determining the starting and endingpositions of a restricted sort key.If the.B \-boption is specified before the first.BI + pos1argument, it is applied to all.BI + pos1arguments.Otherwise, the.B bflag may be attached independently to each.BI + pos1or.BI \- pos2argument..PP.I Pos1and.I pos2each have the form.IB m . noptionally followed by one or more of the flags.BR bdfinr .A starting position specified by.BI + m . nis interpreted to mean the.IR n +1stcharacter in the.IR m +1stfield.A missing.BI . nmeans.BR . 0,indicating the first character of the.IR m +1stfield.If the.B bflag is in effect.I nis counted from the first non-blank in the.IR m +1stfield;.BI + m . \fR0 brefers to the first non-blank character in the.IR m +1stfield..PPA last position specified by.BI \- m . nis interpreted to mean the.IR n thcharacter (including separators) after the last character of the.I m thfield.A missing.BI . nmeans.BR . 0,indicating the last character of the.IR m thfield.If the.B bflag is in effect.I nis counted from the last leading blank in the.IR m +1stfield;.BI \- m . \fR1 brefers to the first non-blank in the.IR m +1stfield..PPWhen there are multiple sort keys, later keysare compared only after all earlier keysare found to be equal.Lines that otherwise compare equal are orderedwith all bytes significant..PP.SH ExamplesSort the contents of.I infilewith the second field as the sort key:.IPsort5 +1 \-2 infile.PPSort, in reverse order, the contents of.I infile1and.IR infile2 ,placing the output in.I outfileand using the first character of the second field as the sort key:.IPsort5 \-r \-o outfile +1.0 \-1.2 infile1 infile2.PPSort, in reverse order, the contents of.I infile1and.I infile2using the first non-blank character of the second field as the sort key:.IPsort5 \-r +1.0b \-1.1b infile1 infile2.PPPrint the password filesorted by the numeric user ID(the third colon-separated field):.IPsort5 \-t: +2n \-3 /etc/passwd.PPPrint the lines of the already sorted file.IR infile ,suppressing all but the first occurrence of lineshaving the same third field(the options.B \-umwith just one input file make the choice of a uniquerepresentative from a set of equal lines predictable):.IPsort5 \-um +2 \-3 infile.SH DiagnosticsComments and exits with non-zero status for various troubleconditions(for example, when input lines are too long),and for disorder discovered under the.B \-coption..PPWhen the last line of an input file is missing a.B new-linecharacter,.I sort5appends one, prints a warning message, and continues..SH Files/usr/tmp/stm???.SH See Alsocomm(1), join(1), uniq(1), setlocale(3int), strcoll(3int)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?