1.\" $OpenBSD: jot.1,v 1.18 2014/01/20 05:07:48 schwarze 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: January 20 2014 $ 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 indicate, respectively, 105the maximum number of data, the lower bound, the upper bound, 106and the step size. 107While at least one of them must appear, 108any of the other three may be omitted, and 109will be considered as such if given as 110.Ql - . 111Any three of these arguments determines the fourth. 112If four are specified and the given and computed values of 113.Ar reps 114conflict, the lower value is used. 115If fewer than three are specified, defaults are assigned 116left to right, except for 117.Ar s , 118which assumes its default unless both 119.Ar begin 120and 121.Ar end 122are given. 123.Pp 124Defaults for the four arguments are, respectively, 125100, 1, 100, and 1. 126.Ar reps 127is expected to be an unsigned integer, 128and if given as zero is taken to be infinite. 129.Ar begin 130and 131.Ar end 132may be given as real numbers or as characters 133representing the corresponding value in ASCII. 134The last argument must be a real number. 135.Pp 136Random numbers are obtained through 137.Xr arc4random 3 . 138Historical versions of 139.Nm 140used 141.Ar s 142to seed the random number generator. 143This is no longer supported. 144The name 145.Nm 146derives in part from 147.Dq iota , 148a function in APL. 149.Ss Rounding and truncation 150The 151.Nm 152utility uses double precision floating point arithmetic internally. 153Before printing a number, it is converted depending on the output 154format used. 155.Pp 156If no output format is specified or the output format is a 157floating point format 158.Po 159.Sq f , 160.Sq e , 161.Sq g , 162.Sq E , 163or 164.Sq G 165.Pc , 166the value is rounded using the 167.Xr printf 3 168function, taking into account the requested precision. 169.Pp 170If 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 , 181or 182.Sq i 183.Pc , 184the value is converted to an integer value by truncation. 185.Pp 186As an illustration, consider the following command: 187.Bd -literal -offset indent 188$ jot 6 1 10 0.5 1891 1902 1912 1922 1933 1944 195.Ed 196.Pp 197By requesting an explicit precision of 1, the values generated before rounding 198can be seen. 199The .5 values are rounded down if the integer part is even, 200up otherwise. 201.Bd -literal -offset indent 202$ jot -p 1 6 1 10 0.5 2031.0 2041.5 2052.0 2062.5 2073.0 2083.5 209.Ed 210.Pp 211By offsetting the values slightly, the values generated by the following 212command are always rounded down: 213.Bd -literal -offset indent 214$ jot -p 0 6 .9999999999 10 0.5 2151 2161 2172 2182 2193 2203 221.Ed 222.Pp 223Another way of achieving the same result is to force truncation by 224specifying an integer format: 225.Bd -literal -offset indent 226$ jot -w %d 6 1 10 0.5 227.Ed 228.Pp 229For random sequences, the output format also influences the range 230and distribution of the generated numbers: 231.Bd -literal -offset indent 232$ jot -r 100000 1 3 | sort -n | uniq -c 23324950 1 23450038 2 23525012 3 236.Ed 237.Pp 238The values at the beginning and end of the interval 239are generated less frequently than the other values. 240There are several ways to solve this problem and generate evenly distributed 241integers: 242.Bd -literal -offset indent 243$ jot -r -p 0 100000 0.5 3.5 | sort -n | uniq -c 24433374 1 24533363 2 24633263 3 247 248$ jot -w %d -r 100000 1 4 | sort -n | uniq -c 24933306 1 25033473 2 25133221 3 252.Ed 253.Pp 254Note that with random sequences, all numbers generated will 255be smaller than the upper bound. 256The largest value generated will be a tiny bit smaller than 257the upper bound. 258For floating point formats, the value is rounded as described 259before being printed. 260For integer formats, the highest value printed will be one less 261than the requested upper bound, because the generated value will 262be truncated. 263.Sh EXAMPLES 264Print 21 evenly spaced numbers increasing from \-1 to 1: 265.Pp 266.Dl $ jot 21 \-1 1.00 267.Pp 268Generate the ASCII character set: 269.Pp 270.Dl $ jot \-c 128 0 271.Pp 272Generate the strings xaa through xaz: 273.Pp 274.Dl $ jot \-w xa%c 26 a 275.Pp 276Generate 20 random 8-letter strings 277(note that the character 278.Sq { 279comes after the character 280.Sq z 281in the ASCII character set): 282.Pp 283.Dl "$ jot \-r \-c 160 a { | rs \-g0 0 8" 284.Pp 285Infinitely many 286.Xr yes 1 Ns 's 287may be obtained through: 288.Pp 289.Dl $ jot \-b yes 0 290.Pp 291Thirty 292.Xr ed 1 293substitution commands applying to lines 2, 7, 12, etc. is the result of: 294.Pp 295.Dl $ jot \-w %ds/old/new/ 30 2 \- 5 296.Pp 297Create a file containing exactly 1024 bytes: 298.Pp 299.Dl $ jot \-b x 512 > block 300.Pp 301To set tabs four spaces apart starting 302from column 10 and ending in column 132, use: 303.Pp 304.Dl $ expand \-`jot \-s, \- 10 132 4` 305.Pp 306To print all lines 80 characters or longer: 307.Pp 308.Dl $ grep `jot \-s \&"\&" \-b . 80` 309.Sh SEE ALSO 310.Xr ed 1 , 311.Xr expand 1 , 312.Xr rs 1 , 313.Xr yes 1 , 314.Xr arc4random 3 , 315.Xr printf 3 316