S
S
shell_guy2021-11-19 16:04:22
bash
shell_guy, 2021-11-19 16:04:22

How to copy text from one file and paste in line 5 14th position?

There are 2 files.
From file1, you need to take the first line and insert it into line 5, 14th position of file2,
tried to push the output of the command into a variable, but it did not work

cat 1.txt | xargs sed -n '5' i `cat 1.txt` 2.txt

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2021-11-19
@saboteur_kiev

It is not entirely clear what is in the 14th position. But maybe you need it?

read LINE <1.txt
sed -r -i "5s/(.{13})(.*)/\1\$LINE\2/" 2.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question