Skip to main content
11 events
when toggle format what by license comment
Aug 21, 2023 at 16:22 answer added Gabriel Coutinho De Miranda timeline score: 0
Feb 9, 2015 at 20:37 answer added don_crissti timeline score: 1
Feb 4, 2015 at 22:06 history edited Gilles 'SO- stop being evil'
edited tags
Feb 4, 2015 at 20:59 comment added orion @mikeserv As I said, if this line happens once, just overwrite it, no problem. But if this grep line happens 200 times in a script, writing once from an array is obviously faster than overwriting 200 times.
Feb 4, 2015 at 18:35 answer added PriB timeline score: -1
Feb 4, 2015 at 9:28 comment added orion You have a few good solutions below, but my question is simply, is this the best way to solve your problem? It makes sense, if this happens once. If you replace several lines in a longer script, it would make more sense to read the file (if it isn't too big) into an array, modify the array, and write it back at the end. That's because replacing a line in the middle is expensive - the entire file has to be overwritten from that point forward (unless you had fixed-width lines, then you could use dd and simply write over the chosen line in-place).
Feb 4, 2015 at 9:25 answer added mikeserv timeline score: 3
Feb 4, 2015 at 8:50 answer added Costas timeline score: 0
Feb 4, 2015 at 6:47 answer added chaos timeline score: 0
Feb 4, 2015 at 6:30 answer added Hauke Laging timeline score: 0
Feb 4, 2015 at 6:21 history asked JigarGandhi CC BY-SA 3.0