Last Updated : 11 Jul, 2025
The 'seq' command in Linux is a powerful utility used to generate a sequence of numbers. It is particularly useful in scenarios where you need to create a list of numbers within loops, such as while, for, or until loops. With 'seq', you can quickly generate numbers from a starting value (FIRST) to an ending value (LAST) with optional increments. Here, we will look into the different ways you can use the 'seq' command and explore its options in more detail.
SyntaxThe 'seq'
command can be used in various formats:
seq [OPTION]... LAST seq [OPTION]... FIRST LAST seq [OPTION]... FIRST INCREMENT LAST
Each of these formats allows you to control the range and step of the sequence generated by the command.
When only one argument is given then it produces numbers from 1 to 'LAST' in step increment of 1. If the 'LAST' is less than 1, then is produces no output.
Example:
seq 102. Generating a Sequence from FIRST to LAST:
When two arguments are given then it produces numbers from 'FIRST' till 'LAST' is step increment of 1. If 'LAST' is less than 'FIRST', then it produces no output.
Example:
seq 3 93. Generating a Sequence with a Specific Increment:
When three arguments are given then it produces numbers from 'FIRST' till 'LAST' in step of 'INCREMENT'. If 'LAST' is less than 'FIRST', then it produces no output.
Example:
seq 3 7 30Advanced Options of 'seq' Command 1. seq -f “FORMAT” FIRST INCREMENT LAST
This command is used to generate sequence in a formatted manner. FIRST and INCREMENT are optional.
Example:
2. seq -s "STRING" FIRST INCREMENT LASTThis command is uses to STRING to separate numbers. By default this value is equal to "\n". FIRST and INCREMENT are optional.
Example:
3. seq -w FIRST INCREMENT LASTThis command is used to equalize width by padding with leading zeroes. FIRST and INCREMENT are optional.
Example:
4. seq --helpIt displays help information. Displays a help message with details about all options and usage of the 'seq' command.
Example:
5. seq --version:It displays version information. Displays the version information of the 'seq' command, which can be useful for troubleshooting compatibility issues.
Example:
The 'seq' command in Linux is a simple and flexible tool used for generating sequences of numbers. It offers various options like formatting the output, setting custom separators, and adding leading zeros to ensure equal width, making it an essential utility for many tasks. By learning how to use 'seq' effectively, you can automate repetitive tasks and improve your scripting abilities, making your workflow smoother and more efficient.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4