firstvar="PRIMARY"
secondvar="SECONDARY"
thirdvar="TERTIARY"
array=($firstvar $secondvar $thirdvar)
echo ${array[*]} //prints PRIMARY SECONDARY TERTIARY
I want to iterate over this array in my bash script, and check if the 3 elements (PRIMARY SECONDARY TERTIARY)
are present in the array with no specific order.
If yes, echo "Success.
If not, echo Failed
. What would be a good way to approach this?
EDIT:
I forgot to mention that if an element(e.g. PRIMARY) is missing from the array, it should also print out Primary is missing.
For a similar array:
array_health=($firsthealth $secondhealth $thirdhealth)
These 3 variables can have either 1 or something else
I want to check whether these 3 variables in the array have value=1, how would I check that? They're not initialized as firsthealth=0
or firsthealth=1
.