【发布时间】:2026-01-01 15:15:02
【问题描述】:
是否可以在 Bash 中取两个数组的差异。有什么好的方法吗?
代码:
Array1=( "key1" "key2" "key3" "key4" "key5" "key6" "key7" "key8" "key9" "key10" )
Array2=( "key1" "key2" "key3" "key4" "key5" "key6" )
Array3 =diff(Array1, Array2)
Array3 ideally should be :
Array3=( "key7" "key8" "key9" "key10" )
【问题讨论】:
-
浏览了解决方案后,我决定在必须对它们进行比较的情况下不使用数组。