Timeline for Adding/inserting different texts to specific intervals of same text file?
Current License: CC BY-SA 4.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 26, 2020 at 14:16 | comment | added | Ed Morton | linux_lover you asked for the simplest solution, not the most robust, or portable or efficient or anything else solution - careful what you wish for! When you talk about a "large" file in the comments above, "large" isn't a problem, "absolutely massive" would be a problem. As @Cbhihe says it'd have to be 10s of gigabytes before it'd be a problem, if your file is just a few million lines then it'd work just fine. There are other differences between how the scripts would handle cases such as add.txt not having as many lines as 1/4 the lines in data.txt and there would be efficiency differences. | |
| Aug 26, 2020 at 12:48 | comment | added | Cbhihe |
@linux_lover: I never said or meant to say that kusalananda's or, for that matter, EdMorton's solution would not work for large files. I only do say that the latter would need more memory for large add.txt files (because in EdMorton's solution the whole file os parsed into his array). For that to be an issue you would probably have to run up add.txt file in the 10s of GB. So i do not believe it is relevant. In a nutshell, both solutions are fine and Kulasananda is likely to use less memory when executing. Is all.
|
|
| Aug 26, 2020 at 10:49 | comment | added | linux_lover |
@Cbhihe Thanks for pointing that out. I am asking this for a clarity: So, you are saying that the solution given by Kusalananda and Ed Morton will not work with very large add.txt?Then what will be the solution that will even work for larger add.txt? Because in near-future I will work with larger add.txt kind-of files.
|
|
| Aug 26, 2020 at 10:46 | comment | added | linux_lover | @Ed Morton your solution is also working smoothly. Many thanks. | |
| Aug 26, 2020 at 6:14 | comment | added | Cbhihe |
You might have to contend with using quite a bit more memory than in Kusalananda's solution in case file add.txt is very large. Kind of a corner case though. ;-)
|
|
| Aug 25, 2020 at 13:15 | history | answered | Ed Morton | CC BY-SA 4.0 |