NUMS

Section: User Commands (1)
Updated: HP Experimental
Index Return to Main Contents
 

NAME

nums - print a list of numbers  

SYNOPSIS

nums [ -lr ] [ -s size ] [ -w width ] value [ value2 ]  

DESCRIPTION

This command prints to standard output all integer values from 1 to value, or if you give two numbers, from value to value2, one number per output line. If value alone is less than 1, or value2 is less than value, it steps backwards rather than forwards.

This command may be useful with "for" loops in shell scripts (see example below) or for generating column headers or row numbers before adding text in an editor.

Options are:

-l
Print all output numbers on a single line, i.e. follow each except the last with a blank instead of a newline.
-r
Print the numbers in random order. A random number generator is seeded to the time plus process number plus real userid plus real groupid. Then successive random values are used to index into an array with one entry for each output value. When the index is of a value already printed, the program searches backward (with wrap-around) for the previous not-yet-printed number, so it terminates in a predictable time.
-s size
Set the step size (increment) to a non-zero integer (default = 1). Starting with the first value, the program steps either forwards or backwards by the given size, as appropriate, until it passes the second value. The sign of size is irrelevant; the direction is determined by the given value(s).
-w width
Right-justify output numbers in fields of at least the given width (columns) by padding with leading blanks as necessary. If width is negative, numbers are left-justified.

Separate options from value with "--" if value is negative.  

EXAMPLES

num 5
Print five lines containing the numbers 1, 2, 3, 4, and 5.
num -l -w4 -- -1 3
Print the numbers -1, 0, 1, 2, and 3 on a single line, each in a field four columns wide (plus leading blank separators), e.g.:
  -1    0    1    2    3
num -rs10 42
Print the numbers 1, 11, 21, 31, and 41 in random order.

for n in `num 20 5`
do
    whatever
done
Do "whatever" 16 times, with "n" set to 20, 19, ..., 5.
 

SEE ALSO

xargs(1), time(2), getpid(2), getuid(2), getgid(2), drand48(3c)  

DIAGNOSTICS

Prints a message to standard error and exits non-zero if invoked wrong or it can't calloc() needed memory for the -r option.  

LIMITATIONS

It doesn't understand real numbers.

If the number of numbers printed is not an integer divisor of the range of the random number generator, the output is not "precisely" random.


 

Index

NAME
SYNOPSIS
DESCRIPTION
EXAMPLES
SEE ALSO
DIAGNOSTICS
LIMITATIONS

This document was created by man2html, using the manual pages.
Time: 06:38:16 GMT, December 12, 2024