Chinaunix

标题: bash的大括号扩展问题 [打印本页]

作者: hzsjx    时间: 2010-03-31 10:40
标题: bash的大括号扩展问题
本帖最后由 hzsjx 于 2010-03-31 10:44 编辑

Bash Reference Manual中有这么一段描述大括号扩展的:
A sequence expression takes the form {x..y[incr]}, where x and y are either integers or single characters, and incr, an optional increment, is an integer. When integers are supplied, the expression expands to each number between x and y, inclusive. Supplied integers may be prefixed with ‘0’ to force each term to have the same width. When either x or y begins with a zero, the shell attempts to force all generated terms to contain the same number of digits, zero-padding where necessary.

但是实际操作下来却没有用“0”填充,还有增量设置好像也不行,哪位高手知道原因?

附我测试结果:
dts@ubuntu1:~$ echo {01..15}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
作者: ywlscpl    时间: 2010-03-31 11:10
以本机bash版本的为准吧,可能版本不同就不支持

man bash 搜索\{.*\.\..*\}
作者: ghp268    时间: 2010-03-31 11:10
我的好像也不支持incr,pad 0倒是可以
  1. echo {01..10}
  2. 01 02 03 04 05 06 07 08 09 10
复制代码

作者: hzsjx    时间: 2010-03-31 12:57
非常感谢ywlscpl,果然是版本问题




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2