First time posting, so please be kind. I am reading through the file "bar" one line at a time and using sed to replace every other line in "foo" (starting with the first line) with the line read from "bar". The code below works, but it is painfully slow when "foo" is 48,890 lines and "bar" is ~24,445 lines (exactly half foo's length).

Does anyone have a recommendation on how to speed this process up?

```
x=1
while read i;do
  sed -i "$x s/^.*$/$i/" foo
  x=$[$x +2]
done < bar

```