bash序列00 01 ... 10 [英] bash sequence 00 01 ... 10
本文介绍了bash序列00 01 ... 10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以bash开头,
$ echo {1..10}
1 2 3 4 5 6 7 8 9 10
我可以得到一个数字序列,但是在某些情况下我需要
I can get a numbers sequence, but in some case I need
01 02 03 ... 10
我怎么能得到这个?
以及如何获得?
001 002 ... 010 011 .. 100
推荐答案
这将在安装了 coreutils
的计算机上的任何外壳中都有效(感谢评论者对我的纠正):
This will work in any shell on a machine that has coreutils
installed (thanks commenters for correcting me):
seq -w 1 10
和
seq -w 1 100
说明:
- 选项
-w
将:
根据需要通过填充零来均衡所有数字的宽度.
Equalize the widths of all numbers by padding with zeros as necessary.
-
seq [-w] [-f格式] [-s字符串] [-t字符串] [第一个[incr]]最后一个
打印一系列数字,每行一个(默认),从第一个(默认为1),尽可能接近最后一个,以incr为增量(默认1).当first大于last时,默认增量为-1
prints a sequence of numbers, one per line (default), from first (default 1), to near last as possible, in increments of incr (default 1). When first is larger than last the default incr is -1
这篇关于bash序列00 01 ... 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文