1.\" $OpenBSD: jot.1,v 1.23 2016/08/12 21:49:31 tb 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 12 2016 $ 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 s 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. 61.It Fl c 62This is an abbreviation for 63.Fl w Ic %c . 64.It Fl n 65Do not print the final newline normally appended to the output. 66.It Fl p Ar precision 67Print only as many digits or characters of the data 68as indicated by the integer 69.Ar precision . 70In the absence of 71.Fl p , 72the precision is the greater of the numbers 73.Ar begin 74and 75.Ar end . 76The 77.Fl p 78option is overridden by whatever appears in a 79.Xr printf 3 80conversion following 81.Fl w . 82.It Fl r 83Generate random data. 84By default, 85.Nm 86generates sequential data. 87.It Fl s Ar string 88Print data separated by 89.Ar string . 90Normally, newlines separate data. 91.It Fl w Ar word 92Print 93.Ar word 94with the generated data appended to it. 95Octal, hexadecimal, exponential, ASCII, zero-padded, 96and right-adjusted representations 97are possible by using the appropriate 98.Xr printf 3 99conversion specification inside 100.Ar word , 101in which case the data is inserted rather than appended. 102.El 103.Pp 104The last four arguments specify the length of the output sequence, 105its start and end points, and the step size. 106Any three of these arguments determine the fourth. 107If the given and computed values for 108.Ar reps 109conflict, the lower value is used. 110.Pp 111Arguments can be omitted by specifying a 112.Ql - . 113The default values for 114.Ar reps , 115.Ar begin , 116.Ar end , 117and 118.Ar s 119are 100, 1, 100, and 1, respectively. 120Omitted values are computed if possible or assume the default. 121A special case arises if only 122.Ar begin 123and 124.Ar end 125are specified: 126if 127.Ar begin 128is greater than 129.Ar end 130then 131.Ar s 132is set to \(mi1, otherwise it is set to 1; 133afterwards 134.Ar reps 135is computed. 136.Pp 137.Ar reps 138is expected to be an unsigned integer, 139and if given as zero is taken to be infinite. 140.Ar begin 141and 142.Ar end 143may be given as real numbers or as characters 144representing the corresponding value in ASCII. 145The last argument must be a real number. 146.Pp 147Random numbers are obtained through 148.Xr arc4random 3 . 149Historical versions of 150.Nm 151used 152.Ar s 153to seed the random number generator. 154This is no longer supported. 155The name 156.Nm 157derives in part from 158.Dq iota , 159a function in APL. 160.Ss Rounding and truncation 161The 162.Nm 163utility uses double precision floating point arithmetic internally. 164Before printing a number, it is converted depending on the output 165format used. 166.Pp 167If no output format is specified or the output format is a 168floating point format 169.Po 170.Sq f , 171.Sq e , 172.Sq g , 173.Sq E , 174or 175.Sq G 176.Pc , 177the value is rounded using the 178.Xr printf 3 179function, taking into account the requested precision. 180.Pp 181If the output format is an integer format 182.Po 183.Sq c , 184.Sq d , 185.Sq o , 186.Sq x , 187.Sq u , 188.Sq D , 189.Sq O , 190.Sq X , 191.Sq U , 192or 193.Sq i 194.Pc , 195the value is converted to an integer value by truncation. 196.Pp 197As an illustration, consider the following command: 198.Bd -literal -offset indent 199$ jot 6 1 10 0.5 2001 2012 2022 2032 2043 2054 206.Ed 207.Pp 208By requesting an explicit precision of 1, the values generated before rounding 209can be seen. 210The .5 values are rounded down if the integer part is even, 211up otherwise. 212.Bd -literal -offset indent 213$ jot -p 1 6 1 10 0.5 2141.0 2151.5 2162.0 2172.5 2183.0 2193.5 220.Ed 221.Pp 222By offsetting the values slightly, the values generated by the following 223command are always rounded down: 224.Bd -literal -offset indent 225$ jot -p 0 6 .9999999999 10 0.5 2261 2271 2282 2292 2303 2313 232.Ed 233.Pp 234Another way of achieving the same result is to force truncation by 235specifying an integer format: 236.Bd -literal -offset indent 237$ jot -w %d 6 1 10 0.5 238.Ed 239.Sh EXAMPLES 240Print 21 evenly spaced numbers increasing from \-1 to 1: 241.Pp 242.Dl $ jot 21 \-1 1.00 243.Pp 244Generate the ASCII character set: 245.Pp 246.Dl $ jot \-c 128 0 247.Pp 248Generate the strings xaa through xaz: 249.Pp 250.Dl $ jot \-w xa%c 26 a 251.Pp 252Generate 20 random 8-letter strings: 253.Pp 254.Dl "$ jot \-r \-c 160 a z | rs \-g0 0 8" 255.Pp 256Infinitely many 257.Xr yes 1 Ns 's 258may be obtained through: 259.Pp 260.Dl $ jot \-b yes 0 261.Pp 262Thirty 263.Xr ed 1 264substitution commands applying to lines 2, 7, 12, etc. is the result of: 265.Pp 266.Dl $ jot \-w %ds/old/new/ 30 2 \- 5 267.Pp 268Create a file containing exactly 1024 bytes: 269.Pp 270.Dl $ jot \-b x 512 > block 271.Pp 272To set tabs four spaces apart starting 273from column 10 and ending in column 132, use: 274.Pp 275.Dl $ expand \-`jot \-s, \- 10 132 4` 276.Pp 277To print all lines 80 characters or longer: 278.Pp 279.Dl $ grep `jot \-s \&"\&" \-b . 80` 280.Sh SEE ALSO 281.Xr ed 1 , 282.Xr expand 1 , 283.Xr rs 1 , 284.Xr yes 1 , 285.Xr arc4random 3 , 286.Xr printf 3 287.Sh HISTORY 288The 289.Nm 290utility first appeared in 291.Bx 4.2 . 292.Sh AUTHORS 293.An John A. Kunze 294