有没有“套路"?bash中的数据结构? [英] Is there a "set" data structure in bash?

查看:24
本文介绍了有没有“套路"?bash中的数据结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python 有一个包含唯一对象的set"类型.Bash 有类似的东西吗?

Python has a "set" type which contains unique objects. Does Bash have something equivalent?

我想继续向这样的 bash集合"添加元素,并且永远不会有重复.

I want to keep adding elements to such a bash "set" and never have duplicates.

推荐答案

Bash 4.0 有关联数组,可以用来构建集合.

Bash 4.0 has associative arrays, which can be used to build sets.

这是一篇讨论它们的文章(这是谷歌第一个搜索bash associative arrays").

Here's an article that discusses them (it was the first Google hit for "bash associative arrays").

(就我个人而言,我只会使用 bash 以外的东西,可能是 Perl.)

(Personally, I'd just use something other than bash, probably Perl.)

这篇关于有没有“套路"?bash中的数据结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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