I am trying to do a comparison to see if these two string arrays match.
I have tried assigning the array variable to another variable to get it to work but i can't figure it out. Here is what I have.
#example of items that could be in the array
#string[1]="TEST"
#string[2]="56486TR126843574TRTEST"
y=${#sting1[@]}
z=${#sting2[@]}
for ((j=0; j<$y; j++))
do
var1=${string1[$j]}
for ((k=0; k<$z; k++))
do
var2=${string2[$k]}
if [ "$var1" = "${*%var2}" ]
then
echo "works"
else
echo "doesn't work
fi
done
done
I want to check and see if string2 has string 1 at the end of it. The length of the numbers in string2 changes with each variable. I would like the if statement to look something like this
if [ "${string1[$j]}" = "${*%sting2[$k]} ]
then
echo "works"
else
echo "doesn't work"
fi
Any help would be appreciated.