The case is to check that all duplicate values have the same index
values are in columns 1-8, index are in column 9-10.
in the first case the first value duplicate (10001010) have index G1, G2 and G3, and also the 3rd value duplicate (10001014) has G1 and G2.
Then I would like to get a output
like this
Value 10001010 has different code G1 G2 G3
Value 10001014 has different code G1 G2
#!/bin/bash
declare -A array
while read line
do
case "${array[${line:0:8}]}" in
*${line:8:2}*)
;;
*)
array[${line:0:8}]="${array[${line:0:8}]} ${line:8:2}";;
esac
done
for val in "${!array[@]}"
do
if [[ ${array[$val]} == \ *\ * ]]
then
echo Value $val has different code ${array[$val]}
found=1
fi
done
[[ -z $found ]] && echo Not errors found