]> git.saurik.com Git - apple/shell_cmds.git/blame - jot/jot.1
shell_cmds-198.tar.gz
[apple/shell_cmds.git] / jot / jot.1
CommitLineData
44bd5ea7
A
1.\" Copyright (c) 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
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. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" @(#)jot.1 8.1 (Berkeley) 6/6/93
f14763b6 33.\" $FreeBSD: src/usr.bin/jot/jot.1,v 1.24 2010/02/20 00:16:44 delphij Exp $
44bd5ea7 34.\"
f14763b6 35.Dd February 19, 2010
44bd5ea7
A
36.Dt JOT 1
37.Os
38.Sh NAME
39.Nm jot
40.Nd print sequential or random data
41.Sh SYNOPSIS
9bafe280
A
42.Nm
43.Op Fl cnr
44bd5ea7
A
44.Op Fl b Ar word
45.Op Fl w Ar word
46.Op Fl s Ar string
47.Op Fl p Ar precision
9bafe280 48.Op Ar reps Op Ar begin Op Ar end Op Ar s
44bd5ea7
A
49.Sh DESCRIPTION
50The
9bafe280 51.Nm
44bd5ea7 52utility is used to print out increasing, decreasing, random,
9bafe280 53or redundant data, usually numbers, one per line.
44bd5ea7
A
54.Pp
55The following options are available:
56.Bl -tag -width indent
57.It Fl r
9bafe280 58Generate random data instead of the default sequential data.
44bd5ea7
A
59.It Fl b Ar word
60Just print
61.Ar word
62repetitively.
63.It Fl w Ar word
64Print
65.Ar word
66with the generated data appended to it.
9bafe280
A
67Octal, hexadecimal, exponential,
68.Tn ASCII ,
69zero padded,
44bd5ea7
A
70and right-adjusted representations
71are possible by using the appropriate
72.Xr printf 3
73conversion specification inside
74.Ar word ,
75in which case the data are inserted rather than appended.
76.It Fl c
9bafe280
A
77This is an abbreviation for
78.Fl w Ar %c .
44bd5ea7
A
79.It Fl s Ar string
80Print data separated by
81.Ar string .
82Normally, newlines separate data.
83.It Fl n
84Do not print the final newline normally appended to the output.
85.It Fl p Ar precision
86Print only as many digits or characters of the data
87as indicated by the integer
88.Ar precision .
89In the absence of
90.Fl p ,
91the precision is the greater of the precisions of
92.Ar begin
93and
94.Ar end .
95The
96.Fl p
97option is overridden by whatever appears in a
98.Xr printf 3
99conversion following
100.Fl w .
101.El
102.Pp
103The last four arguments indicate, respectively,
104the number of data, the lower bound, the upper bound,
105and the step size or, for random data, the seed.
106While at least one of them must appear,
107any of the other three may be omitted, and
108will be considered as such if given as
ddb4a88b
A
109.Fl ""
110or as an empty string.
44bd5ea7
A
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 ,
ddb4a88b 118which assumes a default of 1 or -1 if both
44bd5ea7
A
119.Ar begin
120and
121.Ar end
122are given.
123.Pp
124Defaults for the four arguments are, respectively,
125100, 1, 100, and 1, except that when random data are requested,
9bafe280
A
126the seed,
127.Ar s ,
128is picked randomly.
129The
44bd5ea7 130.Ar reps
9bafe280 131argument is expected to be an unsigned integer,
44bd5ea7 132and if given as zero is taken to be infinite.
9bafe280 133The
44bd5ea7
A
134.Ar begin
135and
136.Ar end
9bafe280
A
137arguments may be given as real numbers or as characters
138representing the corresponding value in
139.Tn ASCII .
44bd5ea7
A
140The last argument must be a real number.
141.Pp
142Random numbers are obtained through
ddb4a88b
A
143.Xr arc4random 3
144when no seed is specified,
145and through
146.Xr random 3
147when a seed is given.
148When
149.Nm
150is asked to generate random integers or characters with begin
151and end values in the range of the random number generator function
152and no format is specified with one of the
153.Fl w ,
154.Fl b ,
155or
156.Fl p
157options,
158.Nm
159will arrange for all the values in the range to appear in the output
160with an equal probability.
161In all other cases be careful to ensure that the output format's
162rounding or truncation will not skew the distribution of output
163values in an unintended way.
164.Pp
44bd5ea7 165The name
9bafe280 166.Nm
44bd5ea7
A
167derives in part from
168.Nm iota ,
169a function in APL.
ddb4a88b
A
170.Sh EXIT STATUS
171.Ex -std
44bd5ea7 172.Sh EXAMPLES
9bafe280 173The command
ddb4a88b
A
174.Dl jot - 1 10
175.Pp
176prints the integers from 1 to 10,
177while the command
9bafe280 178.Dl jot 21 -1 1.00
44bd5ea7 179.Pp
9bafe280
A
180prints 21 evenly spaced numbers increasing from -1 to 1.
181The
182.Tn ASCII
183character set is generated with
184.Dl jot -c 128 0
44bd5ea7 185.Pp
9bafe280
A
186and the strings xaa through xaz with
187.Dl jot -w xa%c 26 a
44bd5ea7 188.Pp
9bafe280
A
189while 20 random 8-letter strings are produced with
190.Dl "jot -r -c 160 a z | rs -g 0 8"
44bd5ea7 191.Pp
9bafe280
A
192Infinitely many
193.Em yes Ns 's
194may be obtained through
195.Dl jot -b yes 0
44bd5ea7 196.Pp
9bafe280 197and thirty
44bd5ea7 198.Xr ed 1
ddb4a88b 199substitution commands applying to lines 2, 7, 12, etc.\& is
9bafe280
A
200the result of
201.Dl jot -w %ds/old/new/ 30 2 - 5
44bd5ea7 202.Pp
ddb4a88b 203The stuttering sequence 9, 9, 8, 8, 7, etc.\& can be
9bafe280
A
204produced by suitable choice of step size,
205as in
206.Dl jot - 9 0 -.5
44bd5ea7 207.Pp
9bafe280
A
208and a file containing exactly 1024 bytes is created with
209.Dl jot -b x 512 > block
44bd5ea7 210.Pp
9bafe280
A
211Finally, to set tabs four spaces apart starting
212from column 10 and ending in column 132, use
213.Dl expand -`jot -s, - 10 132 4`
44bd5ea7 214.Pp
9bafe280
A
215and to print all lines 80 characters or longer,
216.Dl grep `jot -s \&"\&" -b \&. 80`
217.Sh DIAGNOSTICS
9bafe280
A
218The following diagnostic messages deserve special explanation:
219.Bl -diag
220.It "illegal or unsupported format '%s'"
221The requested conversion format specifier for
222.Xr printf 3
223was not of the form
224.Dl %[#][ ][{+,-}][0-9]*[.[0-9]*]?
225where
226.Dq ?\&
227must be one of
228.Dl [l]{d,i,o,u,x}
229or
230.Dl {c,e,f,g,D,E,G,O,U,X}
231.It "range error in conversion"
232A value to be printed fell outside the range of the data type
233associated with the requested output format.
234.It "too many conversions"
235More than one conversion format specifier has been supplied,
236but only one is allowed.
237.El
44bd5ea7
A
238.Sh SEE ALSO
239.Xr ed 1 ,
240.Xr expand 1 ,
241.Xr rs 1 ,
f14763b6 242.Xr seq 1 ,
44bd5ea7 243.Xr yes 1 ,
ddb4a88b 244.Xr arc4random 3 ,
44bd5ea7
A
245.Xr printf 3 ,
246.Xr random 3
ddb4a88b
A
247.Sh HISTORY
248The
249.Nm
250utility first appeared in
251.Bx 4.2 .