logoalt Hacker News

amstantoday at 7:52 AM2 repliesview on HN

Missing (probably because of the date of the article): `mv --exchange` aka renameat2+RENAME_EXCHANGE. It atomically swaps 2 file paths.


Replies

rustybolttoday at 9:19 AM

I tried using this a while back and found it was not widely available. You need coreutils version 9.1 or later for this, many distros do not ship this.

I made https://github.com/rubenvannieuwpoort/atomic-exchange for my usecase.

oguz-ismail2today at 8:02 AM

Title says Unix, renameat2 is Linux-only.

show 1 reply