jot
Print sequential or random data
SYNOPSIS
jot [ options ] [ reps ] [ begin ] [ end ] [ delta ]
PARAMETERS
-a word
Use word as the output instead of numbers. reps copies of word are printed.
-b word
Print word before each value.
-c
Print output as characters instead of numbers, interpreting begin, end, and delta as characters.
-d string
Use string as the separator between values instead of a newline. '\n' or "" are allowed.
-p precision
Specify the precision of the output. If begin, end, or delta are floating point numbers, the output is formatted with precision digits after the decimal point.
-r
Generate random output. If begin and end are given, generate random numbers in the range begin to end inclusive. If only begin is given, generate random numbers from 1 to begin.
-s string
Use string as the separator after each value. A newline is automatically added after the last value.
-w format
Use format as the format string for printf(3) to format the output.
-x
Do not print the final newline.
reps
The number of repetitions to print. Defaults to 1.
begin
The starting value. Defaults to 1.
end
The ending value. Defaults to reps.
delta
The increment between values. Defaults to 1.
DESCRIPTION
The jot command generates sequential or random data, typically numbers, based on the provided parameters. It can be used to create sequences, random number lists, or repeat a given character string. It's a versatile tool for generating input data for scripts, filling arrays, or creating unique identifiers. jot is often more concise and efficient than using loops and incrementing variables within shell scripts. The output can be customized using various formatting options, allowing for precise control over the generated data.
jot is particularly useful for testing, data generation, and prototyping in shell scripting environments.
CAVEATS
The behavior with floating-point numbers and large ranges can sometimes lead to unexpected results due to precision limitations. Be mindful of data types when using the -c option; unexpected characters may arise if the integer range is outside printable ASCII.
EXAMPLES
To print numbers from 1 to 10:jot 10
To print numbers from 5 to 15 with an increment of 2:jot 6 5 15 2
To print the word 'hello' 5 times:jot -a hello 5
To print random numbers between 1 and 100:jot -r 10 1 100
HISTORY
The jot command first appeared in 4.2BSD. It has been a standard utility on BSD systems ever since. It offers a functionality similar to seq, but with different formatting and random number generation capabilities. It has become an indispensable tool in many shell scripting workflows due to its efficiency and flexibility.