3 ms·
The atomicity in the bash version can be "simply" achieved by copying the file to a temporary, modyfing it, then using `sync; mv; sync`, right?
by dpc_01234 3y ago
The atomicity in the bash version can be "simply" achieved by copying the file to a temporary, modyfing it, then using `sync; mv; sync`, right?
- tontinton 3y agoOh you're right I'll add that in later.
- n3storm 3y agoI would go : 1. count records 2. make copy 3. insert 4. ensure records = records + 1 5 if records != records +1 or file can be grepped, stat, filesize, then assume is corrupted and rollback to copy
- o11c 3y agoUse `look` to get `O(log(n))` lookups (writes are still slow, but you could use a multi-level chain I guess). `join` does not use binary search even though it could have.
- tontinton 3y agono waaay, I have never seen look before, thanks!
- deleted 3y ago[deleted]
- ncruces 3y agoAlso, while you're copying you can inverse grep filter to avoid duplicates. And since you're copying, you could maybe ensure sorting, but I don't think doing that with "bash" (plus off the shelf utils) makes a lot of sense. That's what DJBs CDB (cdbget, cdbmake, etc) is for: https://cr.yp.to/cdb.html https://cr.yp.to/cdb.html