seq command in Linux with Examples
seq command in Linux is used to generate numbers from FIRST to LAST in steps of INCREMENT. It is a very useful command where we had to generate list of numbers in while, for, until loop.
Syntax:
seq [OPTION]... LAST or seq [OPTION]... FIRST LAST or seq [OPTION]... FIRST INCREMENT LAST
Options:
- seq LAST: 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.
- seq FIRST 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.
- seq FIRST INCREMENT LAST: 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.
- seq -f “FORMAT” FIRST INCREMENT LAST: This command is used to generate sequence in a formatted manner. FIRST and INCREMENT are optional.
- seq -s “STRING” FIRST INCREMENT LAST: This command is uses to STRING to separate numbers. By default this value is equal to “\n”. FIRST and INCREMENT are optional.
- seq -w FIRST INCREMENT LAST: This command is used to equalize width by padding with leading zeroes. FIRST and INCREMENT are optional.
- seq –help: It displays help information.
- seq –version: It displays version information.
Please Login to comment...