📄 sort.1
字号:
.\" SCCSID: @(#)sort.1 8.1 9/11/90.TH sort 1.SH Namesort \- sort file data.SH Syntax.B sort[\|\fIoptions\fR\|] [\|\fB\-k \fIkeydef\fR\|] [\fB+\fIpos1\fR\|[\fB\-\fIpos2\fR\|]\|] [\|\fIfile\fR...\|] .SH Description.NXR "sort command".NXR "file" "comparing".NXR "file" "merging".NXR "file" "sorting".NXA "sort command" "look command".NXA "sort command" "uniq command"The.PN sortcommandsorts lines of all the named files together and writes the result onthe standard output. The name `\-' means the standard input.If no input files are named, the standard input is sorted..SH Options.NXR "sort command" "options"The default sort key is an entire line.Default ordering is lexicographicby bytes in machine collating sequence.The ordering is affected globally by the following options,one or more of which may appear..IP \fB\-b\fR 12Ignores leading blanks (spaces and tabs) in field comparisons..IP \fB\-d\fRSorts data according to dictionary ordering: letters, digits, and blanks only. .IP \fB\-f\fRFolds uppercase to lowercase while sorting. .IP \fB\-i\fRIgnore characters outside the ASCII range040-0176 in nonnumeric comparisons..IP "\-k \fIkeydef\fR"The \fIkeydef\f argument is a key field definition. The format is.IR field_start ,[\fIfield_end\fP] [\fItype\fP], where.I field_startand.I field_endare the definition of the restricted search key, and .I typeis a modifier from the option list [bdfinr]. These modifiers havethe functionality, for this key only, that their command line counter-parts have for the entire record..IP \fB\-n\fRSorts fields with numbers numerically. An initial numeric string,consisting of optional blanks, optional minus sign,and zero or more digits with optional decimal point,is sorted by arithmetic value. (Note that \-0 is taken to be equal to 0.)Option.B nimplies option.B b..IP \fB\-r\fRReverses the sense of comparisons..IP \fB\-t\fIx\fR Uses specified character as field separator. .PPThe notation.BI + "pos1 " "\-\fIpos2"restricts a sort key to a field beginning at.I pos1and ending just before.IR pos2 ..I Pos1and.I pos2each have the form.IB m . n\fR,optionally followed by one or more of the options.B bdf\&inr,where.I mtells a number of fields to skip from the beginning of the line and.I ntells a number of characters to skip further.If any options are present they override all the globalordering options for this key. If the.B boption is in effect.I nis counted from the first nonblank in the field;.B bis attached independently to .IR pos2 .A missing \&\fB.\fIn\fR means .0; a missing.BI \- pos2means the end of the line. Under the.BI \-t xoption, fields are strings separated by.IR x ;otherwise fields are nonempty nonblank strings separated by blanks..PPWhen there are multiple sort keys, later keysare compared only after all earlier keys compare equal.Lines that otherwise compare equal areordered with all bytes significant..PPThese are additional options:.IP \fB\-c\fR 12Checks sorting order and displays output only if out of order. .IP \fB\-m\fR Merges previously sorted data. .IP "\fB\-o \fIname\fR"Uses specified file as output file. This file may be the same as one of the inputs..IP "\fB\-T \fIdir\fR"Uses specified directory to build temporary files. .IP \fB\-u\fRSuppresses all duplicate entries. Ignored bytes and bytes outsidekeys do not participate in this comparison..SH Examples.NXR(e) "sort command".PPPrint in alphabetical order all the unique spellings in a list of words.Capitalized words differ from uncapitalized..EX.ti +8sort \-u +0f +0 list.EE.PPPrint the password file, sorted by user id number (the 3rd colon-separated field)..EX.ti +8sort \-t: +2n /etc/passwd.EE.PPPrint the first instance of each month in an already sorted fileof (month day) entries.The options.B \-umwith just one input file make the choice of aunique representative from a set of equal lines predictable..EX.ti +8sort \-um +0 \-1 dates.EE.SH Restrictions.NXR "sort command" "restricted"Very long lines are silently truncated..SH Diagnostics.NXR "sort command" "diagnostics"Comments and exits with nonzero status for various troubleconditions and for disorder discovered under option.BR c ..SH Files/usr/tmp/stm*, /tmp/* first and second tries fortemporary files.SH See Alsocomm(1), join(1), rev(1), uniq(1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -