Hi Piers, On Sun, Dec 11, 2022, at 18:11, Piers Rowan via luv-main wrote: > Maybe some progress but this works on a test file: > > sed -i 's/SET SQL_MODE/-- SET SQL_MODE/g' test.sql >
I was putting together some suggestions, but it looks like you've solved this with suggestions from other folk who got in quicker (thanks, other folk). My suggestions were along much the same lines, so no need to repeat them here. Just a few things to note: 1. As you've already realised, sed's "-i", "in-place" option just puts the output into a temporary file, which it then renames, so you have to pass through all the data anyway. And that's pretty much unavoidable, because the modification will change the block-alignment of all the data in the rest of the file (unless you did something weird, like replace the SQL SET command with a comment of exactly the same length). And because sed has to pass through all the data anyway (and generate the temp file), it probably would've been better not to use the "in-place" option, and just put the modified version into a file with a different name (by shell ">" redirection), so as to preserve the original. 2. Also, Emacs compiled for 64-bit architectures should be able to handle ridiculously large file-editing buffers. I've done it, but only by accident. But it would be slower than the streaming sed approach, because Emacs would have to build all the data-structures in-memory, which might have to be swapped out if you don't have enough RAM — all that on top of the (unavoidable) input and output of the data itself (which is all sed would have to do). I expect this would also apply to the Q editor, which Duncan suggested. 3. I assume you have some test machine on which you can restore from the modified backup, to verify that everything works as expected. I hope it all goes well. — Smiles, Les. _______________________________________________ luv-main mailing list -- [email protected] To unsubscribe send an email to [email protected]
