1- .\" $NetBSD: sort.1,v 1.44 2026/01/17 19:29:44 uwe Exp $
1+ .\" $NetBSD: sort.1,v 1.45 2026/01/17 20:40:59 uwe Exp $
22.\"
33.\" Copyright (c) 2000-2003 The NetBSD Foundation, Inc.
44.\" All rights reserved.
7070.Op Fl bdfHilmnrSsu
7171.Oo
7272.Fl k
73- .Ar kstart Ns Op Li \& , Ns Ar kend
73+ .Ar kstart Ns Op Cm \& , Ns Ar kend
7474.Oc
7575.Op Fl o Ar output
7676.Op Fl R Ar char
8282.Op Fl bdfilnru
8383.Oo
8484.Fl k
85- .Ar kstart Ns Op Li \& , Ns Ar kend
85+ .Ar kstart Ns Op Cm \& , Ns Ar kend
8686.Op Fl t Ar char
8787.Oc
8888.Op Fl R Ar char
89- .Op Ar file
89+ .Op Ar
9090.Sh DESCRIPTION
9191The
9292.Nm
@@ -179,17 +179,20 @@ Ignore all non-printable characters.
179179Sort by the string length of the field, not by the field itself.
180180.It Fl n
181181An initial numeric string, consisting of optional blank space, optional
182- plus or minus sign, and zero or more digits (including decimal point)
182+ plus or minus sign, and zero or more digits
183+ .Pq including decimal point
183184.\" with
184185.\" optional radix character and thousands
185186.\" separator
186187.\" (as defined in the current locale),
187188is sorted by arithmetic value.
188- (The
189+ .Po
190+ The
189191.Fl n
190192option no longer implies the
191193.Fl b
192- option.)
194+ option
195+ .Pc .
193196.It Fl r
194197Reverse the sense of comparisons.
195198.El
@@ -208,15 +211,13 @@ option applies globally to all
208211options.
209212Otherwise, the
210213.Fl b
211- option can be attached independently to each
212- .Ar field
213- argument of the
214+ option can be attached independently to each field argument of the
214215.Fl k
215216option (see below).
216217Note that the
217218.Fl b
218219option has no effect unless key fields are specified.
219- .It Fl k Ar kstart Ns Op Li \& , Ns Ar kend
220+ .It Fl k Ar kstart Ns Op Cm \& , Ns Ar kend
220221Designates the starting position,
221222.Ar kstart ,
222223and optional ending position,
@@ -237,11 +238,20 @@ usually produces undesirable results.
237238If char is not a single character, then it
238239specifies the value of the desired record
239240separator as an integer specified in any
240- of the normal NNN, 0ooo, or 0xXXX ways,
241- or as an octal value preceded by \e .
242- Caution: do not attempt to specify Ctl-A
241+ of the normal
242+ .Ar ddd ,
243+ .Li 0 Ns Ar ooo ,
244+ or
245+ .Li 0x Ns Ar hh
246+ ways,
247+ or as an octal value preceded by a backslash
248+ .Pq Ql \e .
249+ .Em Caution :
250+ do not attempt to specify
251+ .Ql \e ^A
252+ .Pq Tn SOH
243253as
244- .Dq -R 1
254+ .Sq Fl R Li 1
245255which will not do what was intended at all!
246256The default record separator is newline.
247257.It Fl t Ar char
@@ -253,9 +263,12 @@ is not considered to be part of a field when determining
253263key offsets (see below).
254264Each occurrence of
255265.Ar char
256- is significant (for example,
257- .Dq Ar charchar
258- delimits an empty field).
266+ is significant
267+ .Po
268+ for example,
269+ .Sq Ao Ar char Ac Ns Aq Ar char
270+ delimits an empty field
271+ .Pc .
259272If
260273.Fl t
261274is not specified, the default field separator is a sequence of
@@ -292,7 +305,7 @@ first field.
292305Fields are specified
293306by the
294307.Fl k
295- .Ar kstart Ns Op \& , Ns Ar kend
308+ .Ar kstart Ns Op Cm \& , Ns Ar kend
296309argument.
297310A missing
298311.Ar kend
@@ -303,91 +316,97 @@ The arguments
303316and
304317.Ar kend
305318have the form
306- .Ar m Ns Li \& . Ns Ar n
319+ .Ar m Ns Op Cm \& . Ns Ar n
320+ .Pq Ar m \^ , n No > 0
307321and can be followed by one or more of the letters
308322.Cm b , d , f , i ,
309323.Cm l , n ,
310324and
311325.Cm r ,
312326which correspond to the options discussed above.
327+ .Pp
313328A
314329.Ar kstart
315330position specified by
316- .Ar m Ns Li \& . Ns Ar n
317- .Pq Ar m , n No > 0
331+ .Ar m Ns Cm \& . Ns Ar n
318332is interpreted as the
319- .Ar n Ns th
333+ .Ar n Ap th
320334character in the
321- .Ar m Ns th
335+ .Ar m Ap th
322336field.
323337A missing
324- .Li \& . Ns Ar n
338+ .Cm \& . Ns Ar n
325339in
326340.Ar kstart
327341means
328- .Ql \& .1 ,
342+ .Sq Cm \& .1 ,
329343indicating the first character of the
330- .Ar m Ns th
344+ .Ar m Ap th
331345field; if the
332346.Fl b
333347option is in effect,
334348.Ar n
335349is counted from the first non-blank character in the
336- .Ar m Ns th
350+ .Ar m Ap th
337351field;
338- .Ar m Ns Li \& .1b
352+ .Ar m Ns Cm \& .1b
339353refers to the first non-blank character in the
340- .Ar m Ns th
354+ .Ar m Ap th
341355field.
342356.Pp
343357A
344358.Ar kend
345359position specified by
346- .Ar m Ns Li \& . Ns Ar n
360+ .Ar m Ns Cm \& . Ns Ar n
347361is interpreted as
348362the
349- .Ar n Ns th
350- character (including separators) of the
351- .Ar m Ns th
363+ .Ar n Ap th
364+ character
365+ .Pq including separators
366+ of the
367+ .Ar m Ap th
352368field.
353369A missing
354- .Li \& . Ns Ar n
370+ .Cm \& . Ns Ar n
355371indicates the last character of the
356- .Ar m Ns th
372+ .Ar m Ap th
357373field;
358374.Ar m
359375= \& 0
360376designates the end of a line.
377+ .Pp
361378Thus the option
362379.Fl k
363380.Sm off
364- .Xo
365- .Ar v Li \& . Ar x Li \& ,
366- .Ar w Li \& . Ar y
367- .Xc
381+ .Ar v Cm \& . Ar x Cm \& , Ar w Cm \& . Ar y
382+ .Sm on
383+ is synonymous with the obsolescent options
384+ .Sm off
385+ .Cm \(pl Ar v \^ Li \- 1 Cm \& . Ar x \^ Li \- 1
368386.Sm on
369- is synonymous with the obsolescent option
370387.Sm off
371- .Cm \(pl Ar v- \& 1 Li \& . Ar x- \& 1
372- .Fl Ar w-\&1 Li \&. Ar y ;
388+ .Fl Ar w\^ Li \-1 Cm \&. Ar y .
373389.Sm on
374- when
390+ .
391+ When
375392.Ar y
376393is omitted,
377394.Fl k
378395.Sm off
379- .Ar v Li \& . Ar x Li \& , Ar w
396+ .Ar v Cm \& . Ar x Cm \& , Ar w
380397.Sm on
381398is synonymous with
382399.Sm off
383- .Cm \(pl Ar v- \& 1 Li \& . Ar x- \& 1
384- .Fl Ar w+1 Li \&.0 .
400+ .Cm \(pl Ar v \^ Li \- 1 Cm \& . Ar x \^ Li \- 1
401+ .Sm on
402+ .Sm off
403+ .Fl Ar w\^ Li +1 Cm \&.0 .
385404.Sm on
386405The obsolescent
387406.Cm \(pl Ns Ar pos1
388407.Fl Ns Ar pos2
389- option is still supported, except for
390- .Fl Ns Ar w Ns Li \&.0b ,
408+ options are still supported, except for
409+ .Fl Ar w Ns Cm \&.0b ,
391410which has no
392411.Fl k
393412equivalent.
@@ -435,19 +454,21 @@ environment variable as the path in which to store
435454temporary files.
436455.El
437456.Sh FILES
438- .Bl -tag -width outputNUMBER+some -compact
457+ .Bl -tag -width " .Ar output \^ Ns Aq Li NUMBER " -compact
439458.It Pa /tmp/sort.*
440459Default temporary files.
441- .It Ar output Ns NUMBER
460+ .It Ar output \^ Ns Aq Li NUMBER
442461Temporary file which is used for output if
443462.Ar output
444463already exists.
445464Once sorting is finished, this file replaces
446465.Ar output
447- (via
466+ .Po
467+ via
448468.Xr link 2
449469and
450- .Xr unlink 2 ) .
470+ .Xr unlink 2
471+ .Pc .
451472.El
452473.Sh EXAMPLES
453474To silently check if the lines in a file are sorted lexicographically,
0 commit comments