← 返回命令列表

Linux command

seq 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Generate numbers from 1 to 10

seq 10

Generate numbers from 5 to 10

seq 5 10

Generate numbers with a step

seq 0 2 10

Generate numbers in reverse

seq 10 -1 1

Generate with leading zeros

seq -w 1 100

Generate with custom separator

seq -s ", " 1 5

Generate with printf-style format

seq -f "file%03g.txt" 1 10

说明

seq prints a sequence of numbers, one per line by default. It's useful for generating numbered lists, loop counters, and formatted sequences in shell scripts. Without a starting number, seq begins at 1. The increment defaults to 1 (or -1 if first > last). Floating-point numbers are supported for all arguments. The -f option accepts printf-style format specifiers: %g for general number, %f for fixed-point, %e for exponential notation. Width and precision modifiers work as in printf. Commonly used in bash loops: for i in $(seq 1 10); do echo $i; done or with brace expansion alternative: for i in {1..10}; do echo $i; done.

参数

-f, --format=_format_
Use printf-style format for output (e.g., %g, %f, %e)
-s, --separator=_string_
Use string as separator (default: newline)
-w, --equal-width
Pad with leading zeros for equal width
--help
Display help and exit
--version
Display version and exit

FAQ

What is the seq command used for?

seq prints a sequence of numbers, one per line by default. It's useful for generating numbered lists, loop counters, and formatted sequences in shell scripts. Without a starting number, seq begins at 1. The increment defaults to 1 (or -1 if first > last). Floating-point numbers are supported for all arguments. The -f option accepts printf-style format specifiers: %g for general number, %f for fixed-point, %e for exponential notation. Width and precision modifiers work as in printf. Commonly used in bash loops: for i in $(seq 1 10); do echo $i; done or with brace expansion alternative: for i in {1..10}; do echo $i; done.

How do I run a basic seq example?

Run `seq 10` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -f, --format=_format_ do in seq?

Use printf-style format for output (e.g., %g, %f, %e)