Annotation of src/usr.bin/jot/jot.1, Revision 1.15
1.15 ! millert 1: .\" $OpenBSD: jot.1,v 1.14 2004/01/01 07:04:10 otto Exp $
1.1 deraadt 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.
1.9 millert 15: .\" 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 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: .\"
1.3 aaron 33: .Dd June 6, 1993
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
1.11 jmc 41: .Bk -words
1.3 aaron 42: .Op Fl cnr
43: .Op Fl b Ar word
1.11 jmc 44: .Op Fl p Ar precision
45: .Op Fl s Ar string
1.3 aaron 46: .Op Fl w Ar word
47: .Oo Ar reps Oo Ar begin Oo Ar end
48: .Oo Ar s Oc Oc Oc Oc
1.11 jmc 49: .Ek
1.3 aaron 50: .Sh DESCRIPTION
51: .Nm
1.1 deraadt 52: is used to print out increasing, decreasing, random,
53: or redundant data, usually numbers, one per line.
1.3 aaron 54: .Pp
55: The options are as follows:
1.11 jmc 56: .Bl -tag -width "-p precision"
1.3 aaron 57: .It Fl b Ar word
1.1 deraadt 58: Just print
1.3 aaron 59: .Ar word
1.1 deraadt 60: repetitively.
1.3 aaron 61: .It Fl c
62: This is an abbreviation for
63: .Fl w Ic %c .
64: .It Fl n
1.1 deraadt 65: Do not print the final newline normally appended to the output.
1.3 aaron 66: .It Fl p Ar precision
1.1 deraadt 67: Print only as many digits or characters of the data
68: as indicated by the integer
1.3 aaron 69: .Ar precision .
1.1 deraadt 70: In the absence of
1.3 aaron 71: .Fl p ,
72: the precision is the greater of the numbers
73: .Ar begin
1.1 deraadt 74: and
1.3 aaron 75: .Ar end .
1.1 deraadt 76: The
1.3 aaron 77: .Fl p
1.1 deraadt 78: option is overridden by whatever appears in a
1.3 aaron 79: .Xr printf 3
1.1 deraadt 80: conversion following
1.3 aaron 81: .Fl w .
1.11 jmc 82: .It Fl r
83: Generate random data.
84: By default,
85: .Nm
86: generates sequential data.
87: .It Fl s Ar string
88: Print data separated by
89: .Ar string .
90: Normally, newlines separate data.
91: .It Fl w Ar word
92: Print
93: .Ar word
94: with the generated data appended to it.
95: Octal, hexadecimal, exponential, ASCII, zero-padded,
96: and right-adjusted representations
97: are possible by using the appropriate
98: .Xr printf 3
99: conversion specification inside
100: .Ar word ,
101: in which case the data is inserted rather than appended.
1.5 aaron 102: .El
1.3 aaron 103: .Pp
1.1 deraadt 104: The last four arguments indicate, respectively,
1.11 jmc 105: the maximum number of data, the lower bound, the upper bound,
1.13 otto 106: and the step size.
1.1 deraadt 107: While at least one of them must appear,
108: any of the other three may be omitted, and
109: will be considered as such if given as
1.3 aaron 110: .Ql - .
1.1 deraadt 111: Any three of these arguments determines the fourth.
112: If four are specified and the given and computed values of
1.3 aaron 113: .Ar reps
1.1 deraadt 114: conflict, the lower value is used.
115: If fewer than three are specified, defaults are assigned
116: left to right, except for
1.3 aaron 117: .Ar s ,
1.1 deraadt 118: which assumes its default unless both
1.3 aaron 119: .Ar begin
1.1 deraadt 120: and
1.3 aaron 121: .Ar end
1.1 deraadt 122: are given.
1.3 aaron 123: .Pp
1.1 deraadt 124: Defaults for the four arguments are, respectively,
1.13 otto 125: 100, 1, 100, and 1.
1.3 aaron 126: .Ar reps
1.1 deraadt 127: is expected to be an unsigned integer,
128: and if given as zero is taken to be infinite.
1.3 aaron 129: .Ar begin
1.1 deraadt 130: and
1.3 aaron 131: .Ar end
1.1 deraadt 132: may be given as real numbers or as characters
133: representing the corresponding value in ASCII.
134: The last argument must be a real number.
1.3 aaron 135: .Pp
1.1 deraadt 136: Random numbers are obtained through
1.12 jmc 137: .Xr arc4random 3 .
1.13 otto 138: Historical versions of
139: .Nm
140: used
141: .Ar s
142: to seed the random number generator.
143: This is no longer supported.
1.1 deraadt 144: The name
1.3 aaron 145: .Nm
1.1 deraadt 146: derives in part from
1.3 aaron 147: .Xr iota ,
1.1 deraadt 148: a function in APL.
1.14 otto 149: .Ss Rounding and truncation
150: The
151: .Nm
152: utility uses double precision floating point arithmetic internally.
153: Before printing a number, it is converted depending on the output
154: format used.
155: .Pp
156: If no output format is specified or the output format is a
157: floating point format
158: .Po
159: .Sq f ,
160: .Sq e ,
161: .Sq g ,
162: .Sq E ,
163: or
164: .Sq G
165: .Pc ,
166: the value is rounded using the
167: .Xr printf 3
168: function, taking into account the requested precision.
169: .Pp
170: If the output format is an integer format
171: .Po
172: .Sq c ,
173: .Sq d ,
174: .Sq o ,
175: .Sq x ,
176: .Sq u ,
177: .Sq D ,
178: .Sq O ,
179: .Sq X ,
180: .Sq U ,
181: or
182: .Sq i
183: .Pc ,
184: the value is converted to an integer value by truncation.
185: .Pp
186: As an illustration, consider the following command:
187: .Bd -literal -offset indent
188: $ jot 6 1 10 0.5
189: 1
190: 2
191: 2
192: 2
193: 3
194: 4
195: .Ed
196: .Pp
197: By requesting an explicit precision of 1, the values generated before rounding
198: can be seen.
199: The .5 values are rounded down if the integer part is even,
200: up otherwise.
201: .Bd -literal -offset indent
202: $ jot -p 1 6 1 10 0.5
203: 1.0
204: 1.5
205: 2.0
206: 2.5
207: 3.0
208: 3.5
209: .Ed
210: .Pp
211: By offsetting the values slightly, the values generated by the following
212: command are always rounded down:
213: .Bd -literal -offset indent
214: $ jot -p 0 6 .9999999999 10 0.5
215: 1
216: 1
217: 2
218: 2
219: 3
220: 3
221: .Ed
222: .Pp
223: Another way of achieving the same result is to force truncation by
224: specifying an integer format:
225: .Bd -literal -offset indent
226: $ jot -w %d 6 1 10 0.5
227: .Ed
228: .Pp
229: For random sequences, the output format also influences the range
230: and distribution of the generated numbers:
231: .Bd -literal -offset indent
232: $ jot -r 100000 1 3 | sort -n | uniq -c
233: 24950 1
234: 50038 2
235: 25012 3
236: .Ed
237: .Pp
238: The values at the beginning and end of the interval
239: are generated less frequently than the other values.
240: There are several ways to solve this problem and generate evenly distributed
241: integers:
242: .Bd -literal -offset indent
243: $ jot -r -p 0 100000 0.5 3.5 | sort -n | uniq -c
244: 33374 1
245: 33363 2
246: 33263 3
247:
248: $ jot -w %d -r 100000 1 4 | sort -n | uniq -c
249: 33306 1
250: 33473 2
251: 33221 3
252: .Ed
253: .Pp
254: Note that with random sequences, all numbers generated will
255: be smaller than the upper bound.
256: The largest value generated will be a tiny bit smaller than
257: the upper bound.
258: For floating point formats, the value is rounded as described
259: before being printed.
260: For integer formats, the highest value printed will be one less
261: than the requested upper bound, because the generated value will
262: be truncated.
1.3 aaron 263: .Sh EXAMPLES
1.11 jmc 264: Print 21 evenly spaced numbers increasing from \-1 to 1:
1.3 aaron 265: .Pp
1.8 deraadt 266: .Dl $ jot 21 \-1 1.00
1.3 aaron 267: .Pp
1.11 jmc 268: Generate the ASCII character set:
1.3 aaron 269: .Pp
1.8 deraadt 270: .Dl $ jot \-c 128 0
1.3 aaron 271: .Pp
1.11 jmc 272: Generate the strings xaa through xaz:
1.3 aaron 273: .Pp
1.8 deraadt 274: .Dl $ jot \-w xa%c 26 a
1.3 aaron 275: .Pp
1.14 otto 276: Generate 20 random 8-letter strings
277: (note that the character
278: .Sq {
279: comes after the character
280: .Sq z
281: in the ASCII character set):
1.3 aaron 282: .Pp
1.15 ! millert 283: .Dl "$ jot \-r \-c 160 a { | rs \-g0 0 8"
1.3 aaron 284: .Pp
1.1 deraadt 285: Infinitely many
1.3 aaron 286: .Xr yes 1 's
1.11 jmc 287: may be obtained through:
1.3 aaron 288: .Pp
1.8 deraadt 289: .Dl $ jot \-b yes 0
1.3 aaron 290: .Pp
1.11 jmc 291: Thirty
1.3 aaron 292: .Xr ed 1
1.11 jmc 293: substitution commands applying to lines 2, 7, 12, etc. is the result of:
1.3 aaron 294: .Pp
1.8 deraadt 295: .Dl $ jot \-w %ds/old/new/ 30 2 \- 5
1.3 aaron 296: .Pp
1.11 jmc 297: Create a file containing exactly 1024 bytes:
1.3 aaron 298: .Pp
1.8 deraadt 299: .Dl $ jot \-b x 512 > block
1.3 aaron 300: .Pp
1.11 jmc 301: To set tabs four spaces apart starting
302: from column 10 and ending in column 132, use:
1.3 aaron 303: .Pp
1.11 jmc 304: .Dl $ expand \-`jot \-s, \- 10 132 4`
1.3 aaron 305: .Pp
1.11 jmc 306: To print all lines 80 characters or longer:
1.3 aaron 307: .Pp
1.11 jmc 308: .Dl $ grep `jot \-s \&"\&" \-b . 80`
1.3 aaron 309: .Sh SEE ALSO
310: .Xr ed 1 ,
311: .Xr expand 1 ,
312: .Xr rs 1 ,
313: .Xr yes 1 ,
1.12 jmc 314: .Xr arc4random 3 ,
315: .Xr printf 3