I am new to Linux and have a challenging task.
I have 3 data files, and need to do the following:
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.
I am open for all suggestions and request the experts to give me suggestions.
I cannot find a reference to the 3rd file in your question, but if you mean replace line number 31 of file 1 with the 1st line of file 2, and replace line number 97 of file 1 with the 2nd line of file 2:
sed -i -e '30R f2
31d;96R f2
97d' f1
The new lines are important after f2 so sed knows that it is the end of the file name.
Note that the R
command is a GNU extension, it is not standard.