From 903775bc5ee9f0b08d86bcf60b03a86f8429b776 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Wed, 15 Jan 2020 11:28:29 +0800 Subject: [PATCH 1/2] PRF @geekpi --- ...ic sequences with the Linux seq command.md | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/translated/tech/20200107 Generating numeric sequences with the Linux seq command.md b/translated/tech/20200107 Generating numeric sequences with the Linux seq command.md index 0b12dfb508..2a99b4b6b3 100644 --- a/translated/tech/20200107 Generating numeric sequences with the Linux seq command.md +++ b/translated/tech/20200107 Generating numeric sequences with the Linux seq command.md @@ -1,6 +1,6 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) +[#]: reviewer: (wxy) [#]: publisher: ( ) [#]: url: ( ) [#]: subject: (Generating numeric sequences with the Linux seq command) @@ -9,10 +9,12 @@ 使用 Linux seq 命令生成数字序列 ====== -Linux seq 命令可以以闪电般的速度生成数字列表。它易于使用而且灵活。 -[Jamie][1] [(CC BY 2.0)][2] -在 Linux 中生成数字列表的最简单方法之一是使用 **seq**(sequence)命令。最简单的形式是,**seq** 接收一个数字,并输出从 1 到该数字的列表。例如: +![](https://img.linux.net.cn/data/attachment/album/202001/15/112717drpb9nuwss84xebu.jpg) + +> Linux 的 seq 命令可以以闪电般的速度生成数字列表,而且它也易于使用而且灵活。 + +在 Linux 中生成数字列表的最简单方法之一是使用 `seq`(系列sequence)命令。其最简单的形式是,`seq` 接收一个数字参数,并输出从 1 到该数字的列表。例如: ``` $ seq 5 @@ -23,7 +25,7 @@ $ seq 5 5 ``` -除非另有指定,否则 **seq** 始终以 1 开头。你可以在最终数字前面插上不同数字开始。 +除非另有指定,否则 `seq` 始终以 1 开头。你可以在最终数字前面插上不同数字开始一个序列。 ``` $ seq 3 5 @@ -34,7 +36,7 @@ $ seq 3 5 ### 指定增量 -你还可以指定增量。假设你要列出 3 的倍数。指定起点(在此示例中为第一个 3 ),增量(第二个 3)和终点(18)。 +你还可以指定增量步幅。假设你要列出 3 的倍数。指定起点(在此示例中为第一个 3 ),增量(第二个 3)和终点(18)。 ``` $ seq 3 3 18 @@ -58,9 +60,7 @@ $ seq 18 -3 3 3 ``` -**seq** 命令也非常快。你或许可以在 10 秒内生成一百万个数字的列表。 - -Advertisement +`seq` 命令也非常快。你或许可以在 10 秒内生成一百万个数字的列表。 ``` $ time seq 1000000 @@ -78,9 +78,9 @@ user 0m0.020s sys 0m0.899s ``` -## 使用分隔符 +### 使用分隔符 -另一个非常有用的选项是使用分隔符。你可以插入逗号,冒号或其他一些字符,而不是在每行上列出单个数字。-s 选项后跟要使用的字符。 +另一个非常有用的选项是使用分隔符。你可以插入逗号、冒号或其他一些字符,而不是在每行上列出单个数字。`-s` 选项后跟要使用的字符。 ``` $ seq -s: 3 3 18 @@ -96,21 +96,21 @@ $ seq -s' ' 3 3 18 ### 开始数学运算 -从生成数字序列到进行数学运算似乎是一个巨大的飞跃,但是有了正确的分隔符,**seq** 可以轻松地传递给 **bc** 进行计算。例如: +从生成数字序列到进行数学运算似乎是一个巨大的飞跃,但是有了正确的分隔符,`seq` 可以轻松地传递给 `bc` 进行计算。例如: ``` $ seq -s* 5 | bc 120 ``` -该命令中发生了什么?让我们来看看。首先,**seq** 生成一个数字列表,并使用 \* 作为分隔符。 +该命令中发生了什么?让我们来看看。首先,`seq` 生成一个数字列表,并使用 `*` 作为分隔符。 ``` $ seq -s* 5 1*2*3*4*5 ``` -然后,它将字符串传递给计算器 (**bc**),计算器立即将数字相乘。你可以在不到一秒的时间内进行相当广泛的计算。 +然后,它将字符串传递给计算器(`bc`),计算器立即将数字相乘。你可以在不到一秒的时间内进行相当庞大的计算。 ``` $ time seq -s* 117 | bc @@ -125,15 +125,13 @@ sys 0m0.000s ### 局限性 -你只能选择一个分隔符,因此计算将非常有限。单独使用 **bc** 可进行更复杂的数学运算。此外,**seq** 仅适用于数字。要生成单个字母序列,请改用如下命令: +你只能选择一个分隔符,因此计算将非常有限。而单独使用 `bc` 可进行更复杂的数学运算。此外,`seq` 仅适用于数字。要生成单个字母的序列,请改用如下命令: ``` $ echo {a..g} a b c d e f g ``` -加入 [Facebook][5] 和 [LinkedIn][6] 上的 Network World 社区,评论热门主题。 - -------------------------------------------------------------------------------- via: https://www.networkworld.com/article/3511954/generating-numeric-sequences-with-the-linux-seq-command.html @@ -141,7 +139,7 @@ via: https://www.networkworld.com/article/3511954/generating-numeric-sequences-w 作者:[Sandra Henry-Stocker][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From f562b347c6ebf6c067f8fc6cc3f9e951ad0c2aec Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Wed, 15 Jan 2020 11:29:01 +0800 Subject: [PATCH 2/2] PUB @geekpi https://linux.cn/article-11784-1.html --- ...Generating numeric sequences with the Linux seq command.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {translated/tech => published}/20200107 Generating numeric sequences with the Linux seq command.md (98%) diff --git a/translated/tech/20200107 Generating numeric sequences with the Linux seq command.md b/published/20200107 Generating numeric sequences with the Linux seq command.md similarity index 98% rename from translated/tech/20200107 Generating numeric sequences with the Linux seq command.md rename to published/20200107 Generating numeric sequences with the Linux seq command.md index 2a99b4b6b3..c04fc6ff3a 100644 --- a/translated/tech/20200107 Generating numeric sequences with the Linux seq command.md +++ b/published/20200107 Generating numeric sequences with the Linux seq command.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) [#]: reviewer: (wxy) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11784-1.html) [#]: subject: (Generating numeric sequences with the Linux seq command) [#]: via: (https://www.networkworld.com/article/3511954/generating-numeric-sequences-with-the-linux-seq-command.html) [#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)