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