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 formated manner. FIRST and INCREMENT are optional.

  • seq -s “STRING” FIRST INCREMENT LAST : This command is uses to STRING to seprate 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.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.