xref: /freebsd/usr.bin/seq/seq.1 (revision de3deff65c5b407ab29b45780f2585b3bc24bbd6)
1.\"
2.\" SPDX-License-Identifier: BSD-2-Clause
3.\"
4.\"	$NetBSD: seq.1,v 1.8 2013/04/07 17:37:45 jdf Exp $
5.\"
6.\" Copyright (c) 2005 The NetBSD Foundation, Inc.
7.\" All rights reserved.
8.\"
9.\" This code is derived from software contributed to The NetBSD Foundation
10.\" by Brian Ginsbach.
11.\"
12.\" Redistribution and use in source and binary forms, with or without
13.\" modification, are permitted provided that the following conditions
14.\" are met:
15.\" 1. Redistributions of source code must retain the above copyright
16.\"    notice, this list of conditions and the following disclaimer.
17.\" 2. Redistributions in binary form must reproduce the above copyright
18.\"    notice, this list of conditions and the following disclaimer in the
19.\"    documentation and/or other materials provided with the distribution.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31.\" POSSIBILITY OF SUCH DAMAGE.
32.\"
33.Dd June 20, 2020
34.Dt SEQ 1
35.Os
36.Sh NAME
37.Nm seq
38.Nd print sequences of numbers
39.Sh SYNOPSIS
40.Nm
41.Op Fl w
42.Op Fl f Ar format
43.Op Fl s Ar string
44.Op Fl t Ar string
45.Op Ar first Op Ar incr
46.Ar last
47.Sh DESCRIPTION
48The
49.Nm
50utility prints a sequence of numbers, one per line
51.Pq default ,
52from
53.Ar first
54.Pq default 1 ,
55to near
56.Ar last
57as possible, in increments of
58.Ar incr
59.Pq default 1 .
60When
61.Ar first
62is larger than
63.Ar last ,
64the default
65.Ar incr
66is -1.
67.Pp
68All numbers are interpreted as floating point.
69.Pp
70Normally integer values are printed as decimal integers.
71.Pp
72The
73.Nm
74utility accepts the following options:
75.Bl -tag -width indent
76.It Fl f Ar format , Fl -format Ar format
77Use a
78.Xr printf 3
79style
80.Ar format
81to print each number.
82Only the
83.Cm A ,
84.Cm a ,
85.Cm E ,
86.Cm e ,
87.Cm F ,
88.Cm f ,
89.Cm G ,
90.Cm g ,
91and
92.Cm %
93conversion characters are valid, along with any optional
94flags and an optional numeric minimum field width or precision.
95The
96.Ar format
97can contain character escape sequences in backslash notation as
98defined in
99.St -ansiC .
100The default is
101.Cm %g .
102.It Fl s Ar string , Fl -separator Ar string
103Use
104.Ar string
105to separate numbers.
106The
107.Ar string
108can contain character escape sequences in backslash notation as
109defined in
110.St -ansiC .
111The default is
112.Cm \en .
113.It Fl t Ar string , Fl -terminator Ar string
114Use
115.Ar string
116to terminate sequence of numbers.
117The
118.Ar string
119can contain character escape sequences in backslash notation as
120defined in
121.St -ansiC .
122This option is useful when the default separator
123does not contain a
124.Cm \en .
125.It Fl w , Fl -fixed-width
126Equalize the widths of all numbers by padding with zeros as necessary.
127This option has no effect with the
128.Fl f
129option.
130If any sequence numbers will be printed in exponential notation,
131the default conversion is changed to
132.Cm %e .
133.El
134.Sh EXIT STATUS
135.Ex -std
136.Sh EXAMPLES
137Generate a sequence from 1 to 3 (included) with a default increment of 1:
138.Bd -literal -offset indent
139# seq 1 3
1401
1412
1423
143.Ed
144.Pp
145Generate a sequence from 3 to 1 (included) with a default increment of -1:
146.Bd -literal -offset indent
147# seq 3 1
1483
1492
1501
151.Ed
152.Pp
153Generate a sequence from 0 to 0.1 (included) with an increment of 0.05 and padding
154with leading zeroes.
155.Bd -literal -offset indent
156# seq -w 0 .05 .1
1570.00
1580.05
1590.10
160.Ed
161.Pp
162Generate a sequence from 1 to 3 (included) with a default increment of 1,
163a custom separator string and a custom terminator:
164.Bd -literal -offset indent
165# seq -s "-->" -t "[end of list]\\n" 1 3
1661-->2-->3-->[end of list]
167.Ed
168.Pp
169Generate a sequence from 1 to 2 (included) with an increment of 0.2 and
170print the results with two digits after the decimal point (using a
171.Xr printf 3
172style format):
173.Bd -literal -offset indent
174# seq -f %.2f 1 0.2 2
1751.00
1761.20
1771.40
1781.60
1791.80
1802.00
181.Ed
182.Sh SEE ALSO
183.Xr jot 1 ,
184.Xr printf 1 ,
185.Xr printf 3
186.Sh HISTORY
187The
188.Nm
189command first appeared in Version\~8
190.At .
191A
192.Nm
193command appeared in
194.Nx 3.0 ,
195and was ported to
196.Fx 9.0 .
197This command was based on the command of the same name in
198Plan 9 from Bell Labs and the GNU core utilities.
199The GNU
200.Nm
201command first appeared in the 1.13 shell utilities release.
202.Sh BUGS
203The
204.Fl w
205option does not handle the transition from pure floating point
206to exponent representation very well.
207The
208.Nm
209command is not bug for bug compatible with other implementations.
210