Hi all,
I would like to combine two arrays and delete duplicates that might occur.
I tried to solve it like this:
Code:
combined=( "${results1[@]}" "${results2[@]}" )
printf "${combined[@]}" | sort -n | uniq
Example:
result1 (4 elements):
newfoo
new foo
oldfoo
new
result2 (4 elements):
new foo
foo
foo new
new
combine (6 elements only):
newfoo
new foo
oldfoo
foo
foo new
new
In my code printf seems to have a problem with elements that have the same letters but a space inbetween. For instance "new foo", "newfoo" are the same for printf :-(
Anybody can help, plz?
Regards & thanks, jomann.