当{Curly Braces}扩展的排列太多时
我知道卷曲括号的扩展是由外壳来处理的,而不是命令,例如回声。当排列太多时,进入命令之前需要太长的内存时间太长。是否有可能让第一个排列馈入命令,然后将第二个排列置于命令中,依此类推。这是因为我在命令中有一个检查条件,因此如果某些排列匹配,则将停止。
echo {a,b,c,d,}{a,b,c,d,}{a,b,c,d,}{a,b,c,d,}{a,b,c,d,}{a,b,c,d,}{a,b,c,d,}{a,b,c,d,}{a,b,c,d,}
可以在shell脚本中通过许多循环来完成。但是,如果有一定的语法允许相同的行为,那将很方便。
I know that the curly braces expansion is handled by the shell, not the command e.g. echo. When there are too many permutations, it takes too long as well as too many memory BEFORE entering the command. Is it possible to let the first permutation feed into the command, then the second permutation, and so on. It is because I have a check condition in the command, such that if certain permutation matches, it will be stopped.
echo {a,b,c,d,}{a,b,c,d,}{a,b,c,d,}{a,b,c,d,}{a,b,c,d,}{a,b,c,d,}{a,b,c,d,}{a,b,c,d,}{a,b,c,d,}
It can be done by many for loops in a shell script. But it would be convenient if there are certain syntax allow the same behaviour.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是通过使用给定的卷曲括号来生成用递归生成排列的想法。
尽管它立即开始产生排列,但要比Bash的支架扩展可能需要更长的时间才能完成。如果这在执行时间不实用,我将使用其他语言(例如Perl)更新我的答案。
Here is an idea to generate the permutations with recursion by using the given string of curly braces.
Although it instantly starts to generate the permutations, it may take a longer time to complete than the brace expansion of bash. If this is not practical in execution time, I'll update my answer with more efficient code using other languages such as perl.