On 2012-07-31 10:59, Adam Thompson wrote:
Err... that does involve the use of temporary files, it's just hidden from you. I'm not aware of any way around that unless the replacement text happen to be exactly the same length (in bytes) as the original text, in which case you need to use dd(1) with skip= and/or seek= to avoid creating a temporary file. Even sed(1) and/or perl(1) with "-i" will create a temporary file behind the scenes, since there's no magic syscall (nor a physical way) to _slide_ the bits forwards or backwards on the disk!
A better way to state my case is 'no temporary files _I_ have to explicitly manage.' I think I'll try a trace on ex and see if it uses a temporary file. I don't see why it wouldn't (as reading in the entire file into a buffer and dumping back to the original file seems kind of dangerous). Academically interesting. I definitely trust the implementation of sed/ed/ex/vi over my scripting abilities to properly manage the temp files. :)
If you're going for ultimate portability, I recommend you fall back to ed(1), since that can be used either as-is with ed(1) or with patch(1). The command-line invocation will be slightly uglier than than with ex(1), however.
Agreed. The ex trick worked _very_ well. Deployment went smoothly on all 30 odd hosts.