How to generate a sequence of numbers using the Linux seq command
This article mainly explains "how to use the Linux seq command to generate a digital sequence". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use the Linux seq command to generate a digital sequence.
Linux's seq command can generate a list of numbers at lightning speed, and it is easy to use and flexible.
One of the easiest ways to generate a list of numbers in Linux is to use the seq (Series sequence) command. In its simplest form, seq takes a numeric parameter and outputs a list from 1 to that number. For example:
$seq 512345
Seq always starts with 1 unless otherwise specified. You can insert different numbers in front of the final number to start a sequence.
$seq 3 5345 specify increment
You can also specify incremental strides. Suppose you want to list multiples of 3. Specify the start point (the first 3 in this example), the increment (the second 3), and the end point (18).
$seq 3 3 18369121518
You can choose to use negative increments (that is, decrements) to change the number from large to small.
$seq 18-3 3181512963
The seq command is also very fast. You may be able to generate a list of a million numbers in 10 seconds.
$time seq 1000000123. 9999989999991000000 real 0m9.290s