免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3510 | 回复: 3

bash的大括号扩展问题 [复制链接]

论坛徽章:
1
2017金鸡报晓
日期:2017-02-08 10:33:21
发表于 2010-03-31 10:40 |显示全部楼层
本帖最后由 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

论坛徽章:
0
发表于 2010-03-31 11:10 |显示全部楼层
以本机bash版本的为准吧,可能版本不同就不支持

man bash 搜索\{.*\.\..*\}

论坛徽章:
0
发表于 2010-03-31 11:10 |显示全部楼层
我的好像也不支持incr,pad 0倒是可以
  1. echo {01..10}
  2. 01 02 03 04 05 06 07 08 09 10
复制代码

论坛徽章:
1
2017金鸡报晓
日期:2017-02-08 10:33:21
发表于 2010-03-31 12:57 |显示全部楼层
非常感谢ywlscpl,果然是版本问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP