E
E
ekholdthero2020-10-04 15:40:49
linux
ekholdthero, 2020-10-04 15:40:49

Stack output of two files?

There is a 1.txt file with content

123а
456b

There is also a 2.txt file with the content
789а
012b

How to make output to file 3.txt with the total content of two files, that is, so that file 3.txt has the sum of 123a+789a and the sum of 456b+012b?
In file 3.txt, you need to get the sum of these values, that is
912а
468b

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Pavlov, 2020-10-04
@ekholdthero


How to output to 3.txt file with sum content of two files

Through programming

S
Saboteur, 2020-10-05
@saboteur_kiev

Depends on the exact task.
if you have a and b are line markers, then in the loop you read the lines of the first file, find the letter, use it to grep the second file, get the two necessary lines. You fold and write in the third.
If it's just lines in order - and they always match in number, then you can simply read two files into separate arrays in a loop and then go through the loop again.
If there are always three digits in each line, you can cut through ${variable:0:3}, if different - you can use a regular expression.
You would show how you tried to do and what exactly you do not work out. And it looks like you want someone to do your homework for you. And with this - freelance.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question