Skip to content
Advertisement

How do I replace all lines after line XX in one file with content from another file?

I’m on Debian 8.2. Here’s test.sh so far.

JavaScript

I want lines 26 onwards of fileA‘s content to replace everything in fileB from line 26 onward — so I end up with the first 25 lines of the output are from lines 1-25 of the original fileB and the remainder is lines 26 onwards of fileA.

How do I do this?

Advertisement

Answer

JavaScript

head -25 will take first 25 lines from fileB and dump it to tempfile. Then tempfile will be renamed to fileB.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement