R
R
ross_viktor2019-10-15 14:18:02
bash
ross_viktor, 2019-10-15 14:18:02

How to substitute one text file at the beginning of another in mac?

hello, tell me, I have 2 text files file1.txt and file2.txt in each of them 3000 lines, I need to substitute each line of the first file at the beginning and / or at the end (tell me both that and that option) from the second file, let's say there are 3 lines in the first file
text1
text2
text3
in the second file
-123
-124
-125
the result
is text1-123
text-124
text-125
how to do it in the terminal?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Barbolin, 2019-10-15
@ross_viktor

i=0; for line1 in `cat file1.txt`; do i=$[i+1] ; line2=`cat file2.txt | awk NR==$i`; echo $line1 - $line2; done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question