[RndTbl] Little script puzzle help.
sean at tinfoilhat.ca
Mon Jul 30 22:42:07 CDT 2012
On 2012-07-30, at 7:26 PM, Mike Pfaiffer wrote:
> I'm going to think a little outside the box. The lines you want to insert into the existing file... Is there a pattern? Can they be generated ahead of time and stored in temporary files? I gather the lines are consecutive... If all this is the case then all you have to do is determine the start and end of the section you want to replace. I think you could then use head, cat, and tail to recreate the file you want then just mv it.
You are thinking along the right lines though I answered a few of those points already.
The lines I'm replaceing with is already in a file (replacement.txt) and the chunk of stuff I'm replacing will be between lines 23 and 56 of the file. The contents of lines 23 through 56 may have different values on each host but they will be represented.
Building up with head and tail is not a bad approach but requires the use of a temporary file and if this data set was huge would be a bit cumbersome (if you use /tmp via mktemp which is could be different file system etc.).
This is not a good problem for cat though... head and tail is serviceable. Thanks for your thoughts on this.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Roundtable