I'm currently trying to use the following code to merge two input files:
for i in `cat $file1`; do
for j in `cat $file2`; do
printf "%s %s\n" "$i" "$j"
done
done
Given files created as follows:
printf '%s\n' A B C >file1
printf '%s\n' 1 2 3 >file2
...my expected/desired output is:
A 1
B 2
C 3
But instead, the output I'm getting is:
A 1
A 2
A 3
B 1
B 2
B 3
C 1
C 2
C 3
How can this be fixed?