Brace expansion with range in fish shell

橙三吉。 提交于 2019-11-29 01:45:50

问题


In bash, I can do the following

$ echo bunny{1..6}
bunny1 bunny2 bunny3 bunny4 bunny5 bunny6

Is there a way to achieve the same result in fish?


回答1:


The short answer is echo bunny(seq 6)

Longer answer: In keeping with fish's philosophy of replacing magical syntax with concrete commands, we should hunt for a Unix command that substitutes for the syntactic construct {1..6}. seq fits the bill; it outputs numbers in some range, and in this case, integers from 1 to 6. fish (to its shame) omits a help page for seq, but it is a standard Unix/Linux command.

Once we have found such a command, we can leverage command substitutions. The command (foo)bar performs command substitution, expanding foo into an array, and may result in multiple arguments. Each argument has 'bar' appended.



来源:https://stackoverflow.com/questions/20770836/brace-expansion-with-range-in-fish-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!