I hope this is not off topic.
I have to save output from a command to file, but only if length of this output is positive. I've thought about two solutions:
- save output to a python variable, check length, if positive save to destination file;
- save output to a temporary file, check length, if positive rename to destination file.
Is there any best practice for this little problem, or which one usually performs better between my proposed solutions?
- file length is usually 1KB
- we are not using ssds, usually 7200rpm hard disk
- average RAM is usually 10-20 GB
- I don't know if filesystem is important, anyway ext3
I know this is a bit unclear, but I was hoping there was some best practice to apply in this case.