shell支持set吗?
bash 和 ksh 等 shell 是否支持集合操作(例如“两个集合的并集”)?我无法使用谷歌找到任何关于此的教程。
Do shells such as bash and ksh support set operations (such as 'union of two sets')? I can't find any tutorial about this using Google.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这个set-operations-in-unix-shell怎么样。
What about this set-operations-in-unix-shell.
据我所知,POSIX shell(包括bash)不支持集合操作。但是您可以构建自己的数组,例如,通过使用 bash 关联数组(bash 4.0 及更高版本)。
As far as I know, POSIX shell (including bash) doesn't support sets operation. But you can build your own, for example, by making use of bash associative array (bash 4.0 and later).
No bash/ksh 不支持专用集操作。如果您坚持使用 shell,则必须自己编写程序。就像 xdazz 提供的链接所做的那样。如果您想要完全专用的集合操作(也在性能方面),请使用真正的编程语言(例如Python、Ruby等)
No bash/ksh doesn't support dedicated sets operations. You will have to program your own if you insists on using the shells..like what the link xdazz provided has done. If you want full dedicated set operations (also in terms of performance), use a real programming language (eg Python, Ruby etc )
它可以通过编写类似于在 Makefile 中编写的定义来执行设置操作:
它非常酷,您应该检查一下。我个人不推荐“unix shell 中的设置操作”帖子。当您确实需要执行许多集合操作或者您有任何相互依赖的集合操作时,它不会很好地工作。
无论如何,我认为它非常酷,你应该完全检查一下。
I wrote a program recently called Setdown that does Set operations from the cli.
It can perform set operations by writing a definition similar to what you would write in a Makefile:
Its pretty cool and you should check it out. I personally don't recommend the "set operations in unix shell" post. It won't work well when you really need to do many set operations or if you have any set operations that depend on eachother.
At any rate, I think that it's pretty cool and you should totally check it out.