Skip to content

Instantly share code, notes, and snippets.



Created Mar 27, 2019
What would you like to do?
Example to create an exclusive temp/working dir in bash using the atomicity of mkdir without -p
# example
# create an exclusive temp dir
# atomic mkdir op method
# allow bash-isms
mkdir -p "${b%/*}" || exit 1
n=0 x="${b}_00000000"
until mkdir "${x}" ;do printf -v x "%s_%08d" "${b}" $((++n)) ;done
echo "${x}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.