Home > OS >  The sed command line insert file
The sed command line insert file

Time:09-21

From a file read 3 to 4 lines, inserted into another file after the line 5 of the sed command line only, not write a shell script, no logic programming language, such as a command line can solve best,
Just learning the sed, thought of this problem, but do not to come out, thank you.

CodePudding user response:

Because of two file operations, so can only think of using two sed.
Sed -n '3, 4 w temp_file file1 & amp; & Sed -i '5 r temp_file file2

CodePudding user response:

Sed - n '3, 4 p' 111. TXT | xargs 1 - I - n {} sed -i '5 s/^/{} \ n/' 222. TXT

Separated with a space by default, if 3, 4 line with no Spaces, can use this
  • Related