Bash 生成庞大的数字列表
我正在尝试生成一个巨大的序列号列表,填充为0Bash 生成庞大的数字列表,bash,scripting,operations,largenumber,Bash,Scripting,Operations,Largenumber,我正在尝试生成一个巨大的序列号列表,填充为0 for example: 00000000 00000001 00000002 . . 99999997 99999998 99999999 我在尝试类似于: for i in $(seq 00000000 99999999);do echo ${i} >> filelist.txt;done 这有两个问题 1: the range is too big and the system cant handle it
for example:
00000000
00000001
00000002
.
.
99999997
99999998
99999999
我在尝试类似于:
for i in $(seq 00000000 99999999);do echo ${i} >> filelist.txt;done
这有两个问题
1: the range is too big and the system cant handle it
2: the numbers arent padded so I end up with something like this:
1
2
3
.
.
998
999
1000
非常感谢您的帮助。
seq
已经知道如何填充
seq -w 00000000 00000009 >filelist.txt
对于更通用的格式,还有
-f
(当增量不是整数时最有用)。对于更复杂的输出,最好的解决方案是使用sed
或其他文本处理工具对seq
的输出进行后处理
seq 10 > file
while read i; do printf "%.8d\n" $i; done < file
00000001
00000002
00000003
00000004
00000005
00000006
00000007
00000008
00000009
00000010
seq 10>文件
当我读书时;不打印“%.8d\n”$i;完成<文件
00000001
00000002
00000003
00000004
00000005
00000006
00000007
00000008
00000009
00000010
您的解决方案比我的好得多,我没有阅读手册,这是对的:-)