Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 bash 中,我可以执行以下操作
$ echo bunny{1..6} bunny1 bunny2 bunny3 bunny4 bunny5 bunny6
有没有办法在鱼身上达到同样的效果?
简短的回答是echo bunny(seq 6)
echo bunny(seq 6)
更长的答案:为了与 fish 用具体命令代替魔法语法的哲学保持一致,我们应该寻找一个替代语法结构的 Unix 命令{1..6}。seq符合要求;它输出某个范围内的数字,在这种情况下,是从 1 到 6 的整数。fish(可惜)省略了 的帮助页面seq,但它是标准的 Unix/Linux 命令。
{1..6}
seq
一旦我们找到这样的命令,我们就可以利用命令替换。该命令(foo)bar执行命令替换,扩展foo为一个数组,并可能导致多个参数。每个参数都附加了“bar”。
(foo)bar
foo