In the following shell script, I use two arrays to store the numbers in p1.txt and p2.txt and then display them.
cat p1.txt | awk '{for(i=1;i<NF;i++) {party1[$i-1]=$i}}'
cat p2.txt | awk '{for(j=1;j<NF;j++) {party2[$j-1]=$j}}'
for ((k=1;k<10;k++))
do
echo "${party1[$k]}"
echo "${party2[$k]}"
done
However, when I run it with the default sh, it says Syntax error: Bad for loop variable; when I run it with bash, no numbers can be displayed. What's wrong with the script?
for (( ... )); do. Use bash.