Q:

Append from nth to nth index of a file with another file

File 1:
1000000010019000000000012001011234567001011234567 2019013120190131
1000000010019000000000012001011234567001011234567 2019013120190131
1000000010019000000000012001011234567001011234567 2019013120190131
1000000010019000000000012001011234567001011234567 2019013120190131
1000000010019000000000012001011234567001011234567 2019013120190131
1000000010019000000000012001011234567001011234567 2019013120190131

File 2:
ABCDEFGHIJKLMNO
ZAEDWQOIRPFJVND
SDEOIMFUJRKDMEU
WOQOEMFJCMSKSLD
XNCJFURYYEJWODK
EIWKEMDLDDLFMVM

Output File:
10000000100190000000000ABCDEFGHIJKLMNO12001011234567001011234567 2019013120190131
10000000100190000000000ZAEDWQOIRPFJVND12001011234567001011234567 2019013120190131
10000000100190000000000SDEOIMFUJRKDMEU12001011234567001011234567 2019013120190131
10000000100190000000000WOQOEMFJCMSKSLD12001011234567001011234567 2019013120190131
10000000100190000000000XNCJFURYYEJWODK12001011234567001011234567 2019013120190131
10000000100190000000000EIWKEMDLDDLFMVM12001011234567001011234567 2019013120190131

Here i need to append the content of File 2 into File 1 from nth to nth index of File 1.
awk '$0=substr($0,1,10)"X"substr($0,12,length($0))' input.txt > output.txt

The above awk command works well for a file as input.But i need a variable as a input whose value will be changing for every line.
Read value from file 2 and append to file 1. From nth to nth index.

A:

You are almost there. Please try the following:
awk 'NR==FNR {line[FNR]=$0; next} {print substr($0,1,23) line[FNR] substr($0,24,length($0))}' file2 file1

yields:
10000000100190000000000ABCDEFGHIJKLMNO12001011234567001011234567 2019013120190131
10000000100190000000000ZAEDWQOIRPFJVND12001011234567001011234567 2019013120190131
10000000100190000000000SDEOIMFUJRKDMEU12001011234567001011234567 2019013120190131
10000000100190000000000WOQOEMFJCMSKSLD12001011234567001011234567 2019013120190131
10000000100190000000000XNCJFURYYEJWODK12001011234567001011234567 2019013120190131
10000000100190000000000EIWKEMDLDDLFMVM12001011234567001011234567 2019013120190131

[Explanation]

The script first reads "file2" and stores the lines in an array line indexed by the line number FNR.
Next the script reads "file1" and insert the line in the array associated by FNR.

[Edit]
Here is a bash only alternative just in case:
paste -d "" <(cut -b 1-23 file1) file2 <(cut -b 24- file1)

Hope this helps.

