TrumanWong

seq

Print numbers starting from the first digit to the last digit in the specified increment

Supplementary instructions

seq command is used to generate all integers from a certain number to another number.

grammar

seq [options]... mantissa
seq [option]... leading number mantissa
seq [option]... leading number increment mantissa

Options

-f, --format=format Use printf-style floating point formatting
-s, --separator=string Use the specified string to separate numbers (default: \n)
-w, --equal-width Add 0 before columns to make them the same width

Example

-f option: specify format

#seq -f"%3g" 9 11
9
10
11

The number of digits specified after % is %g by default. If %3g is used, the missing digits are spaces.

#sed -f"%03g" 9 11
#seq -f"str%03g" 9 11
str009
str010
str011

In this case, the missing number of digits is 0, and the character string is specified before %.

-w option: Specify that the output numbers are the same width

seq -w 98 101
098
099
100
101

Cannot be used with -f, the output is the same width.

-s option: specify the delimiter (default is carriage return)

seq -s" " -f"str%03g" 9 11
str009 str010 str011

To specify /t as the delimiter:

seq -s"`echo -e "/t"`" 9 11

Specify \n as the delimiter:

seq -s"`echo -e "\n"`" 9 11
19293949596979899910911

What you get is an error result, but it is generally not necessary. The default is carriage return as the separator.