(zsh括号扩展| seq)字符列表 - 如何? [英] (zsh brace expansion | seq) for character lists - how?

查看:250
本文介绍了(zsh括号扩展| seq)字符列表 - 如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Bash允许我写在{h..k}中的语句

Bash allows me to write the statement,

$ for i in {h..k} ; do echo $i ; done

但zsh只允许数列表扩展,例如 {8..13 }

but zsh only allows number list expansion such as {8..13}.

最好的解决方法是什么?像 seq 字符...

What's the best workaround? Something like seq for characters...

推荐答案

由于这仍然是最热门的google结果,更新答案:

As this is still a top google result, an updated answer:

当前版本支持bash style {c1..c2} 其中 c1 c2 是字符:

The current release supports bash style {c1..c2} where c1 and c2 are characters:


形式' {c1。 .c2} ',其中 c1 c2 是单字符(可以是多字节字符)扩展到从 c1 c2 范围内的每个字符,无论内部使用什么字符序列。对于代码点低于128的字符,这是US ASCII(这是大多数用户将需要的唯一情况)。如果任何中间字符不可打印,则使用适当的引用使其可打印。如果字符序列被颠倒,则输出是相反的顺序,例如。 ' {d..a} '替换为 dcba '。

An expression of the form ‘{c1..c2}’, where c1 and c2 are single characters (which may be multibyte characters), is expanded to every character in the range from c1 to c2 in whatever character sequence is used internally. For characters with code points below 128 this is US ASCII (this is the only case most users will need). If any intervening character is not printable, appropriate quotation is used to render it printable. If the character sequence is reversed, the output is in reverse order, e.g. ‘{d..a}’ is substituted as ‘d c b a’.

这在5.0.7版本中肯定存在。我在 zsh发布历史记录中引入的时候似乎找不到,但记录它的第一个归档版本表示它是在2012年7月到2014年11月之间推出的。

This is definitely present in 5.0.7 onwards. I can't seem to find when this was introduced in the zsh release history, but the first archived version documenting it indicates it was introduced between July 2012 and November 2014.

这篇关于(zsh括号扩展| seq)字符列表 - 如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆