Answer the question
In order to leave comments, you need to log in
How to write a simple Bash loop that will compare the contents of arrays?
Good afternoon,
there are three arrays. The first with the user ID, two with the same number of indexes but different values, but only 0 or 1, this is the user's status in different systems, is it active. It is necessary to write a cycle (function) that will compare the array indices one by one and do something.
For example, if the index 1451 in the first array is greater than in the second one, then write the user ID + the final value of the status comparison from the two arrays True.
I did something like this but it doesn't work.
for i in "{${#STATUS_AR[@]}}"; do
if [ "$STATUS_AR[$i]" -lt "$STATUS_AD_AR[$i]" ]; then
echo "True"
fi
done
Answer the question
In order to leave comments, you need to log in
I wrote such a thing to remove elements from the first array that are in the second:
for USER in "${!USER_LIST[@]}"
do
for EXCEPTION in "${EXCEPTION_LIST[@]}"
do
if
then
unset USER_LIST[$USER]
fi
done
done
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question