At a previous job I remember a PR to do essentially
temp=$(mktemp -d)
mv $target $temp
rm -r $temp &
I thought it was pretty clever. Obviously you would need to make sure mktemp is on the same filesystem (there are good flags to just use a dot file in the current directory). mv is atomic on most filesystems and then the & just runs the rm in the background .
At a previous job I remember a PR to do essentially
temp=$(mktemp -d) mv $target $temp rm -r $temp &
I thought it was pretty clever. Obviously you would need to make sure mktemp is on the same filesystem (there are good flags to just use a dot file in the current directory). mv is atomic on most filesystems and then the & just runs the rm in the background .
I fail to see the benefit of that script.