Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use the Linux seq command to generate a sequence of numbers (recommended)

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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 5

one

two

three

four

five

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 5

three

four

five

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 18

three

six

nine

twelve

fifteen

eighteen

You can choose to use negative increments (that is, decrements) to change the number from large to small.

$seq 18-3 3

eighteen

fifteen

twelve

nine

six

three

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. 9999989999991000000real 0m9.290s

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report