I am new to Linux and have a challenging task.
I have 3 data files, and need to do the following:
Go to line 31 of file 1, delete it
Read 1 line from file 2 and add in place of deleted line
Go to line 97 of file I delete it and then read the line 1 from file 2 and add in place of that deleted file.
The thing is also important to keep the same file i.e file , it is not to be changed.
I tried different versions of sed and perl, with buffer copying tricks but was not successful. :wall:
I am open for all suggestions and request the experts to give me suggestions.
Does that do it? I feel a proper sed or awk would be better if the files are large. Additionally, remember the vi has limitation such as maximum line length and space for the temporary files it uses, often in /var
You would need to check the exact records this catches as head & tail vary accourding to OS version. You also cannot write this back to file1 until you have created the replacement file, so you might hit space issues.
Could you expand on the reasons for the edit and sizes of files etc.
I hope that this helps if it's a small enough file to be processed each time.