3 ms·
That's not it. Between [ -f file.txt ] && rm file.txt and rm -f file.txt the latter form is preferrable because it is easier and not as prone to concur
by xorcist 5y ago
That's not it.
Between
[ -f file.txt ] && rm file.txt
and
rm -f file.txt
the latter form is preferrable because it is easier and not as prone to concurrency problems.
Although it should be said that concurrency and idempotency is seldom acquired just by using force-flags in isolated spots, the whole operation needs to take it into account. There are probably more steps involved than just removing one file. The linked article leaves out the bigger picture so it's probably not very helpful. Often it is sufficient to construct the new state under a temporary name and then move it in place in one operation.