Substitute specific lines with lines from another file
Hello All,
I have two files called old-matter and new-matter # cat old-matter abc: this, is a, sample, entry byi: white board, is white in color rtz: black, board is black qty: i tried, a lot asd: no solutions, found for this task abc: this is, the second, sample entry byi: second, entry of white board rtz: second, entry of black board qty: second, entry of trying asd: second, entry of no solutions abc: this is, the third, sample entry byi: third, entry of white board rtz: third, entry of black board qty: third, entry of trying asd: third, entry of no solutions ...... ...... ... and so on up to 1517 entries in this file, from the line begining with asd: to line ends with asd: is considered as one entry (or a paragraph). now i had created another file called new-matter, which is having ONLY the first line of the above said each entries(paragraph) in the newly formatted style, as the following; abc: newly updated, this, is a, sample, entry abc: newly updated, this is, the second, sample entry abc: newly updated, this is, the third, sample entry, with more info .... .... 1517 lines Now i need to replace all the lines in the old-matter, which starts with abc: with the newly formatted abc: lines from the new-matter file. Here the critical thing, is, it should be replaced correctly (first paragraphs abc: should replace with first abc: in the new-matter and so on...), bcoz all the new entries are Uniq (this is actually an address list). Also i need to put a blank line above all the line starts with abc: Thanks in Advance... |
Code:
#!/usr/bin/env perl |
Really thanking you
jcookeman,
Really Really Really thanks a million.....:):):) It was an urgent need for me and i was trying lot of things on the same. Now you had saved my time... Thanks dear.... thanks a lot. Now can u send me one more info, how to put a blank line over all the lines which starts with abc: Once again thanks a lot... |
When you did `cat old-matter` it shows lines already there.
If there are no blank lines there it substantially changes the logic. |
it can also be solved using the following command:
Quote:
|
All times are GMT -5. The time now is 10:23 AM. |