I guess this one earns me the award for the most bloated approach: #!/bin/bash file=val.txt i=0 while IFS= read -r -n1 val_char do x_array[i]=$val_char let i++ done < "$file" j=0 array_count=0 while [ ${x_array[j]} != "" ] do if [ ${x_array[j]} != 'x' ] then final_array[$array_co...