In linux can you copy one file into another file at a specific line(using a terminal command)?
Ex.
File 1:
this is
file 1
File 2:
this is
file 2
New File:
this is
this is
file 2
file 1
In linux can you copy one file into another file at a specific line(using a terminal command)?
Ex.
File 1:
this is
file 1
File 2:
this is
file 2
New File:
this is
this is
file 2
file 1
On
I don't think there's any native command to do this, but you could do it at least a couple of ways.
1a. file chunk1 = head _n_ lines of file 1
1b. file chunk2 = tail _m_ lines of file 1
1c. cat chunk1 file_2 chunk2 > new_file
or write a simple script (e.g., in Perl) to
2a. read _n_ lines of file 1 and write them out to new_file
2b. read file 2 and write it out to new_file
2c. finish reading remaining lines of file 1 and write them out to new_file
you could use paste