When I use the paste command in the terminal window it works fine, but when i try to use it in a bash script file i get errors. I'm not sure how to use the paste command in a bash script file.
bash provides many functionalities that sh does not, for instance "process substitution" that you use in your code sample.
You need to output to two files, and paste those, or you need to play dirty tricks, like
$ mkfifo J
$ { code1; } | paste - J & # paste stdin and the FIFO; put in background
$ { code2; } > J # print to FIFO
$ rm J
Generally, I don't consider using fifo's to be in any way dirty. However, the way you're using one here is unreliable. The successful completion of your approach depends on several factors:
The shell's execution environment. If job control is enabled, each background job runs in its own process group. Background process groups may not be able to write to the terminal.
Terminal settings. If tostop is enabled (see stty), writes to the terminal by a process not in the foreground process group triggers SIGTTOU signals to all processes in the process group.
Process signal masks. If the writing process is blocking or ignoring SIGTTOU, then the signal isn't sent to the process group.
The following approach could be stopped as soon as paste tries to write.
mkfifo f1
cat <<EOF | paste - f1 &
1
2
3
EOF
cat <<EOF >f1
a
b
c
EOF
For a more reliable approach, I would suggest using a second fifo:
mkfifo f1 f2
cat <<EOF >f1 &
1
2
3
EOF
cat <<EOF >f2 &
a
b
c
EOF
paste f1 f2