The SEQ command briefly describes the SEQ command, which is a more appropriate tool for generating a sequence when a loop is needed, and the usual method is simple:
Usage:seq [OPTION] ... Last seq [OPTION] ... First last seq [OPTION] ... First INCREMENT lastprint numbers from first to last, in steps of increment.# prints numbers from first through last with INCREMENT as step
its parameters are also relatively simple, mainly have the following several:# Specify format-F,--format=format use printf style floating-point format # Specify delimiter-S,--separator=string use STRING to S Eparate numbers (default: \ n) # Equal width parameters are useful in daily work. -W,--equal-width equalize width by padding with leading zeroes basic usage
The default delimiter is newline (\ n)
thatsit:~ # seq 1 201234567891011121314151617181920thatsit:~ #
# Specify a space delimiter
thatsit:~ # seq-s "" 1 201 2 3 4 5 6 7 8 9 All in one of the ten 20thatsit:~ #
# using equal width parameters
thatsit:~ # Seq-w-S "" 1 2001-A-ten-one-off-20thatsit:~ #
Advanced usage is primarily based on the use of the-f parameter, which can be obtained using info seq. You can specify format with printf to output a sequence of two-bit precision floating-point numbers, decimal (default), 16-binary, octal, and so on: The following is a demonstration of SEQ 1 20 (a space is used in printf to separate data):
Decimal (default):
Octal:
thatsit:~ # printf '%o ' Seq 1 ' 1 2 3 4 5 6 7-one-off-ten-24thatsit:~ #
Hexadecimal:
thatsit:~ # printf '%x ' seq 1 ' 1 2 3 4 5 6 7 8 9 a B c D E F ten-14thatsit:~ #
Floating-point number with two-digit precision:
thatsit:~ # printf '%.2f ' seq 1 20 ' 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.0 0 17.00 18.00 19.00 20.00thatsit:~ #
Floating-point number with four-digit precision:
thatsit:~ # printf '%.4f ' seq 1 20 ' 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.000 0 13.0000 14.0000 15.0000 16.0000 17.0000 18.0000 19.0000 20.0000thatsit:~ #
Others
In addition, there are a number of scientific methods, such as the format, generally not used, to understand the following:
such as:%e,%e, a%, a%, etc.
The SEQ of the Linux command