awkfilemerge

How to combine rows from two files?


I have file1:

1
5
4

and file 2:

44
65
56

I want to file.out:

1
44
5
65
4
56

Thank you


Solution

  • use paste with custom delimiter \n i.e line feed:

    paste -d '\n' file1 file2 > file.out
    

    or GNU sed:

    sed 'R file2' file1
    

    or awk:

    awk 'NR==FNR{a[NR]=$0;next} {print a[FNR]} 1' file1 file2