Check whether length of two array is same or not in Linux

In this blog, sharing code to check whether length of two arrays is same or not.

arr=(4 3 2 1) ## First Array of 4 elements
arr_2=(4 3 1 10 1) ## Second Array of 5 elements
len_arr=${#arr[@]}
len_arr_2=${#arr_2[@]}
if [ $len_arr -eq $len_arr_2 ]
then
echo "Length of both Array is same"
fi
if [ $len_arr -ne $len_arr_2 ]
then
echo "Length of both Array is not same"
fi

Related posts