xref: /openbsd/usr.bin/jot/jot.1 (revision d89ec533)
1.\"	$OpenBSD: jot.1,v 1.25 2021/08/13 11:27:33 martijn Exp $
2.\"	$NetBSD: jot.1,v 1.2 1994/11/14 20:27:36 jtc Exp $
3.\"
4.\" Copyright (c) 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"	@(#)jot.1	8.1 (Berkeley) 6/6/93
32.\"
33.Dd $Mdocdate: August 13 2021 $
34.Dt JOT 1
35.Os
36.Sh NAME
37.Nm jot
38.Nd print sequential or random data
39.Sh SYNOPSIS
40.Nm jot
41.Bk -words
42.Op Fl cnr
43.Op Fl b Ar word
44.Op Fl p Ar precision
45.Op Fl s Ar string
46.Op Fl w Ar word
47.Oo Ar reps Oo Ar begin Oo Ar end
48.Oo Ar step Oc Oc Oc Oc
49.Ek
50.Sh DESCRIPTION
51.Nm
52is used to print out increasing, decreasing, random,
53or redundant data, usually numbers, one per line.
54.Pp
55The options are as follows:
56.Bl -tag -width "-p precision"
57.It Fl b Ar word
58Just print
59.Ar word
60repetitively.
61Overrides earlier
62.Fl b ,
63.Fl c ,
64and
65.Fl w .
66.It Fl c
67This is an abbreviation for
68.Fl w Ic %c .
69Overrides earlier
70.Fl b
71and
72.Fl w .
73.It Fl n
74Do not print the final newline normally appended to the output.
75.It Fl p Ar precision
76Print only as many digits or characters of the data
77as indicated by the integer
78.Ar precision .
79In the absence of
80.Fl p ,
81the precision is the greater of the numbers
82.Ar begin
83and
84.Ar end .
85The
86.Fl p
87option is overridden by whatever appears in a
88.Xr printf 3
89conversion following
90.Fl w .
91.It Fl r
92Generate random data.
93By default,
94.Nm
95generates sequential data.
96.It Fl s Ar string
97Print data separated by
98.Ar string .
99Normally, newlines separate data.
100.It Fl w Ar word
101Print
102.Ar word
103with the generated data appended to it.
104Octal, hexadecimal, exponential, ASCII, zero-padded,
105and right-adjusted representations
106are possible by using the appropriate
107.Xr printf 3
108conversion specification inside
109.Ar word ,
110in which case the data is inserted rather than appended.
111Overrides earlier
112.Fl b ,
113.Fl c ,
114and
115.Fl w .
116.El
117.Pp
118The last four arguments specify the length of the output sequence,
119its start and end points, and the step size.
120Any three of these arguments determine the fourth.
121If the given and computed values for
122.Ar reps
123conflict, the lower value is used.
124.Pp
125Arguments can be omitted by specifying a
126.Ql - .
127The default values for
128.Ar reps ,
129.Ar begin ,
130.Ar end ,
131and
132.Ar step
133are 100, 1, 100, and 1, respectively.
134Omitted values are computed if possible or assume the default.
135A special case arises if only
136.Ar begin
137and
138.Ar end
139are specified:
140if
141.Ar begin
142is greater than
143.Ar end
144then
145.Ar step
146is set to \(mi1, otherwise it is set to 1;
147afterwards
148.Ar reps
149is computed.
150.Pp
151.Ar reps
152is expected to be an unsigned integer,
153and if given as zero is taken to be infinite.
154.Ar begin
155and
156.Ar end
157may be given as real numbers or as characters
158representing the corresponding value in ASCII.
159The last argument must be a real number.
160.Pp
161Random numbers are obtained through
162.Xr arc4random 3 .
163Historical versions of
164.Nm
165used
166.Ar step
167to seed the random number generator.
168This is no longer supported.
169The name
170.Nm
171derives in part from
172.Dq iota ,
173a function in APL.
174.Ss Rounding and truncation
175The
176.Nm
177utility uses double precision floating point arithmetic internally.
178Before printing a number, it is converted depending on the output
179format used.
180.Pp
181If no output format is specified or the output format is a
182floating point format
183.Po
184.Sq f ,
185.Sq e ,
186.Sq g ,
187.Sq E ,
188or
189.Sq G
190.Pc ,
191the value is rounded using the
192.Xr printf 3
193function, taking into account the requested precision.
194.Pp
195If the output format is an integer format
196.Po
197.Sq c ,
198.Sq d ,
199.Sq o ,
200.Sq x ,
201.Sq u ,
202.Sq D ,
203.Sq O ,
204.Sq X ,
205.Sq U ,
206or
207.Sq i
208.Pc ,
209the value is converted to an integer value by truncation.
210.Pp
211As an illustration, consider the following command:
212.Bd -literal -offset indent
213$ jot 6 1 10 0.5
2141
2152
2162
2172
2183
2194
220.Ed
221.Pp
222By requesting an explicit precision of 1, the values generated before rounding
223can be seen.
224The .5 values are rounded down if the integer part is even,
225up otherwise.
226.Bd -literal -offset indent
227$ jot -p 1 6 1 10 0.5
2281.0
2291.5
2302.0
2312.5
2323.0
2333.5
234.Ed
235.Pp
236By offsetting the values slightly, the values generated by the following
237command are always rounded down:
238.Bd -literal -offset indent
239$ jot -p 0 6 .9999999999 10 0.5
2401
2411
2422
2432
2443
2453
246.Ed
247.Pp
248Another way of achieving the same result is to force truncation by
249specifying an integer format:
250.Bd -literal -offset indent
251$ jot -w %d 6 1 10 0.5
252.Ed
253.Sh EXAMPLES
254Print 21 evenly spaced numbers increasing from \-1 to 1:
255.Pp
256.Dl $ jot 21 \-1 1.00
257.Pp
258Generate the ASCII character set:
259.Pp
260.Dl $ jot \-c 128 0
261.Pp
262Generate the strings xaa through xaz:
263.Pp
264.Dl $ jot \-w xa%c 26 a
265.Pp
266Generate 20 random 8-letter strings:
267.Pp
268.Dl "$ jot \-r \-c 160 a z | rs \-g0 0 8"
269.Pp
270Infinitely many
271.Xr yes 1 Ns 's
272may be obtained through:
273.Pp
274.Dl $ jot \-b yes 0
275.Pp
276Thirty
277.Xr ed 1
278substitution commands applying to lines 2, 7, 12, etc. is the result of:
279.Pp
280.Dl $ jot \-w %ds/old/new/ 30 2 \- 5
281.Pp
282Create a file containing exactly 1024 bytes:
283.Pp
284.Dl $ jot \-b x 512 > block
285.Pp
286To set tabs four spaces apart starting
287from column 10 and ending in column 132, use:
288.Pp
289.Dl $ expand \-`jot \-s, \- 10 132 4`
290.Pp
291To print all lines 80 characters or longer:
292.Pp
293.Dl $ grep `jot \-s \&"\&" \-b . 80`
294.Sh SEE ALSO
295.Xr ed 1 ,
296.Xr expand 1 ,
297.Xr rs 1 ,
298.Xr yes 1 ,
299.Xr arc4random 3 ,
300.Xr printf 3
301.Sh HISTORY
302The
303.Nm
304utility first appeared in
305.Bx 4.2 .
306.Sh AUTHORS
307.An John A. Kunze
308