lobase

Linux port of OpenBSDs userland.

jot.1 (6667B)


      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
     52 is used to print out increasing, decreasing, random,
     53 or redundant data, usually numbers, one per line.
     54 .Pp
     55 The options are as follows:
     56 .Bl -tag -width "-p precision"
     57 .It Fl b Ar word
     58 Just print
     59 .Ar word
     60 repetitively.
     61 .It Fl c
     62 This is an abbreviation for
     63 .Fl w Ic %c .
     64 .It Fl n
     65 Do not print the final newline normally appended to the output.
     66 .It Fl p Ar precision
     67 Print only as many digits or characters of the data
     68 as indicated by the integer
     69 .Ar precision .
     70 In the absence of
     71 .Fl p ,
     72 the precision is the greater of the numbers
     73 .Ar begin
     74 and
     75 .Ar end .
     76 The
     77 .Fl p
     78 option is overridden by whatever appears in a
     79 .Xr printf 3
     80 conversion following
     81 .Fl w .
     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.
    102 .El
    103 .Pp
    104 The last four arguments specify the length of the output sequence,
    105 its start and end points, and the step size.
    106 Any three of these arguments determine the fourth.
    107 If the given and computed values for
    108 .Ar reps
    109 conflict, the lower value is used.
    110 .Pp
    111 Arguments can be omitted by specifying a
    112 .Ql - .
    113 The default values for
    114 .Ar reps ,
    115 .Ar begin ,
    116 .Ar end ,
    117 and
    118 .Ar s
    119 are 100, 1, 100, and 1, respectively.
    120 Omitted values are computed if possible or assume the default.
    121 A special case arises if only
    122 .Ar begin
    123 and
    124 .Ar end
    125 are specified:
    126 if
    127 .Ar begin
    128 is greater than
    129 .Ar end
    130 then
    131 .Ar s
    132 is set to \(mi1, otherwise it is set to 1;
    133 afterwards
    134 .Ar reps
    135 is computed.
    136 .Pp
    137 .Ar reps
    138 is expected to be an unsigned integer,
    139 and if given as zero is taken to be infinite.
    140 .Ar begin
    141 and
    142 .Ar end
    143 may be given as real numbers or as characters
    144 representing the corresponding value in ASCII.
    145 The last argument must be a real number.
    146 .Pp
    147 Random numbers are obtained through
    148 .Xr arc4random 3 .
    149 Historical versions of
    150 .Nm
    151 used
    152 .Ar s
    153 to seed the random number generator.
    154 This is no longer supported.
    155 The name
    156 .Nm
    157 derives in part from
    158 .Dq iota ,
    159 a function in APL.
    160 .Ss Rounding and truncation
    161 The
    162 .Nm
    163 utility uses double precision floating point arithmetic internally.
    164 Before printing a number, it is converted depending on the output
    165 format used.
    166 .Pp
    167 If no output format is specified or the output format is a
    168 floating point format
    169 .Po
    170 .Sq f ,
    171 .Sq e ,
    172 .Sq g ,
    173 .Sq E ,
    174 or
    175 .Sq G
    176 .Pc ,
    177 the value is rounded using the
    178 .Xr printf 3
    179 function, taking into account the requested precision.
    180 .Pp
    181 If 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 ,
    192 or
    193 .Sq i
    194 .Pc ,
    195 the value is converted to an integer value by truncation.
    196 .Pp
    197 As an illustration, consider the following command:
    198 .Bd -literal -offset indent
    199 $ jot 6 1 10 0.5
    200 1
    201 2
    202 2
    203 2
    204 3
    205 4
    206 .Ed
    207 .Pp
    208 By requesting an explicit precision of 1, the values generated before rounding
    209 can be seen.
    210 The .5 values are rounded down if the integer part is even,
    211 up otherwise.
    212 .Bd -literal -offset indent
    213 $ jot -p 1 6 1 10 0.5
    214 1.0
    215 1.5
    216 2.0
    217 2.5
    218 3.0
    219 3.5
    220 .Ed
    221 .Pp
    222 By offsetting the values slightly, the values generated by the following
    223 command are always rounded down:
    224 .Bd -literal -offset indent
    225 $ jot -p 0 6 .9999999999 10 0.5
    226 1
    227 1
    228 2
    229 2
    230 3
    231 3
    232 .Ed
    233 .Pp
    234 Another way of achieving the same result is to force truncation by
    235 specifying an integer format:
    236 .Bd -literal -offset indent
    237 $ jot -w %d 6 1 10 0.5
    238 .Ed
    239 .Sh EXAMPLES
    240 Print 21 evenly spaced numbers increasing from \-1 to 1:
    241 .Pp
    242 .Dl $ jot 21 \-1 1.00
    243 .Pp
    244 Generate the ASCII character set:
    245 .Pp
    246 .Dl $ jot \-c 128 0
    247 .Pp
    248 Generate the strings xaa through xaz:
    249 .Pp
    250 .Dl $ jot \-w xa%c 26 a
    251 .Pp
    252 Generate 20 random 8-letter strings:
    253 .Pp
    254 .Dl "$ jot \-r \-c 160 a z | rs \-g0 0 8"
    255 .Pp
    256 Infinitely many
    257 .Xr yes 1 Ns 's
    258 may be obtained through:
    259 .Pp
    260 .Dl $ jot \-b yes 0
    261 .Pp
    262 Thirty
    263 .Xr ed 1
    264 substitution 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
    268 Create a file containing exactly 1024 bytes:
    269 .Pp
    270 .Dl $ jot \-b x 512 > block
    271 .Pp
    272 To set tabs four spaces apart starting
    273 from column 10 and ending in column 132, use:
    274 .Pp
    275 .Dl $ expand \-`jot \-s, \- 10 132 4`
    276 .Pp
    277 To 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
    288 The
    289 .Nm
    290 utility first appeared in
    291 .Bx 4.2 .
    292 .Sh AUTHORS
    293 .An John A. Kunze