I'm trying to combine two files at certain locations using awk
/sed
/forloop
/foreach
... whichever is the most simple.
First, I have file 1 which has ...
#
#
>
#
#
>
etc..
And in my second file, I have just numbers (as many numbers as >'s in the other file).
Num1
Num2
Num3
etc...
I want to insert the numbers in order in file 2, after each > in the first file, such as...
#
#
> Num1
#
#
> Num2
Thanks!
Short awk
solution:
awk '/^>/{ r=$0; if ((getline < "file2") > 0) $0=r OFS $0 }1' file1
Sample output:
#
#
> Num1
#
#
> Num2