Paste every other line?

Hi!

I have two files that look like this:

File1
A
B
C
D
E
F
...

File2
Z
Y
X
W
V
U
...

and would like to merge them to form an output file like this:

Output
A
BY
C
DW
E
FU
...

Basically every other line of the second file should be pasted onto every other line of the first file, preferably without tab or any other delimiter.
How do I manage this?

Hi Limmnes,

One way using perl:

$ cat file1
A
B
C
D
E
F
$ cat file2
Z
Y
X
W
V
U
$ cat script.pl
use warnings;
use strict;

die qq[Usage: perl $0 <file-1> <file-2>\n] unless @ARGV == 2;

open my $fh1, qq[<], shift @ARGV or die qq[ERROR: $!\n];
open my $fh2, qq[<], shift @ARGV or die qq[ERROR: $!\n];

while ( my $data1 = <$fh1>, my $data2 = <$fh2> ) {
        chomp ($data1, $data2);
        if ( $. % 2 == 0 ) {
                printf qq[%s%s\n], $data1, $data2;
        }
        else {
                printf qq[%s\n], $data1;
        }
}
$ perl script.pl file{1,2}
A
BY
C
DW
E
FU
awk '{ b=""; getline b<"File2" }; b && ((NR+1)%2) { $0=$0 b } 1' File1
# awk 'NR==FNR{a[++x]=$1;next}{i++;if(i%2==1||i==0){printf "%s\n",a;}else{printf "%s",a;}};{if(FNR%2=1)printf "%s\n",$1}' file1 file2
A
BY
C
DW
E
FU
paste file1 file2 | awk 'NR%2{$2=x}{sub("\t",x)}1'
awk '{getline p<f} !(NR%2){$2=p}1' OFS= f=file2 file1