【发布时间】:2016-01-14 05:16:03
【问题描述】:
我有两个数组,比如说:
arr1=("one" "two" "three")
arr2=("two" "four" "six")
在 Bash 中合并这两个数组的最佳方法是什么?
【问题讨论】:
-
实际联合(没有重复)或只是两个数组串联?
-
实际并集(不重复)
-
在zsh中你可以使用
typeset -U arr,很确定在bash中没有这么简单的方法。 -
@Kevin 如何使用
typeset -U arr? -
@denysdovhan
typeset -u arr; arr=(a b a c); echo $arr # prints a b c.