2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" @(#)jot.1 8.1 (Berkeley) 6/6/93
30 .Dd September 21, 2019
35 .Nd print sequential or random data
43 .Op Ar reps Op Ar begin Op Ar end Op Ar s
47 utility is used to print out increasing, decreasing, random,
48 or redundant data, usually numbers, one per line.
50 The following options are available:
51 .Bl -tag -width indent
53 Generate random data instead of the default sequential data.
61 with the generated data appended to it.
62 Octal, hexadecimal, exponential,
65 and right-adjusted representations
66 are possible by using the appropriate
68 conversion specification inside
70 in which case the data are inserted rather than appended.
72 This is an abbreviation for
75 Print data separated by
77 Normally, newlines separate data.
79 Do not print the final newline normally appended to the output.
81 Print only as many digits or characters of the data
82 as indicated by the integer
86 the precision is the greater of the precisions of
92 option is overridden by whatever appears in a
98 The last four arguments indicate, respectively,
99 the number of data, the lower bound, the upper bound,
100 and the step size or, for random data, the seed.
101 While at least one of them must appear,
102 any of the other three may be omitted, and
103 will be considered as such if given as
105 or as an empty string.
106 Any three of these arguments determines the fourth.
107 If four are specified and the given and computed values of
109 conflict, the lower value is used.
110 If one or two are specified, defaults are assigned
113 which assumes a default of 1 (or -1 if
117 specify a descending range).
118 Then the default values are assigned to the leftmost omitted arguments until
119 three arguments are set.
121 Defaults for the four arguments are, respectively,
122 100, 1, 100, and 1, except that when random data are requested,
128 argument is expected to be an unsigned integer,
129 and if given as zero is taken to be infinite.
134 arguments may be given as real numbers or as characters
135 representing the corresponding value in
137 The last argument must be a real number.
139 Random numbers are obtained through
141 when no seed is specified,
144 when a seed is given.
147 is asked to generate random integers or characters with begin
148 and end values in the range of the random number generator function
149 and no format is specified with one of the
156 will arrange for all the values in the range to appear in the output
157 with an equal probability.
158 In all other cases be careful to ensure that the output format's
159 rounding or truncation will not skew the distribution of output
160 values in an unintended way.
167 .Ss Rounding and truncation
170 utility uses double precision floating point arithmetic internally.
171 Before printing a number, it is converted depending on the output
174 If no output format is specified or the output format is a
175 floating point format
184 the value is rounded using the
186 function, taking into account the requested precision.
188 If the output format is an integer format
202 the value is converted to an integer value by truncation.
204 As an illustration, consider the following command:
205 .Bd -literal -offset indent
215 By requesting an explicit precision of 1, the values generated before rounding
217 The .5 values are rounded down if the integer part is even,
219 .Bd -literal -offset indent
220 $ jot -p 1 6 1 10 0.5
229 By offsetting the values slightly, the values generated by the following
230 command are always rounded down:
231 .Bd -literal -offset indent
232 $ jot -p 0 6 .9999999999 10 0.5
241 Another way of achieving the same result is to force truncation by
242 specifying an integer format:
243 .Bd -literal -offset indent
244 $ jot -w %d 6 1 10 0.5
252 prints the integers from 1 to 10,
256 prints 21 evenly spaced numbers increasing from -1 to 1.
259 character set is generated with
262 and the strings xaa through xaz with
265 while 20 random 8-letter strings are produced with
266 .Dl "jot -r -c 160 a z | rs -g 0 8"
270 may be obtained through
275 substitution commands applying to lines 2, 7, 12, etc.\& is
277 .Dl jot -w %ds/old/new/ 30 2 - 5
279 The stuttering sequence 9, 9, 8, 8, 7, etc.\& can be
280 produced by truncating the output precision and a suitable choice of step size,
282 .Dl jot -w %d - 9.5 0 -.5
284 and a file containing exactly 1024 bytes is created with
285 .Dl jot -b x 512 > block
287 Finally, to set tabs four spaces apart starting
288 from column 10 and ending in column 132, use
289 .Dl expand -`jot -s, - 10 132 4`
291 and to print all lines 80 characters or longer,
292 .Dl grep `jot -s \&"\&" -b \&. 80`
294 The following diagnostic messages deserve special explanation:
296 .It "illegal or unsupported format '%s'"
297 The requested conversion format specifier for
300 .Dl %[#][ ][{+,-}][0-9]*[.[0-9]*]?
306 .Dl {c,e,f,g,D,E,G,O,U,X}
307 .It "range error in conversion"
308 A value to be printed fell outside the range of the data type
309 associated with the requested output format.
310 .It "too many conversions"
311 More than one conversion format specifier has been supplied,
312 but only one is allowed.
326 utility first appeared in